@@ -407,20 +407,22 @@ pure function descriptor_name(descriptor) result(name)
407
407
end function descriptor_name
408
408
409
409
! > Archive a folder using `git archive`.
410
- subroutine git_archive (source , destination , ref , verbose , error )
410
+ subroutine git_archive (source , destination , ref , additional_files , verbose , error )
411
411
! > Directory to archive.
412
412
character (* ), intent (in ) :: source
413
413
! > Destination of the archive.
414
414
character (* ), intent (in ) :: destination
415
415
! > (Symbolic) Reference to be archived.
416
416
character (* ), intent (in ) :: ref
417
+ ! > (Optional) list of additional untracked files to be added to the archive.
418
+ character (* ), optional , intent (in ) :: additional_files(:)
417
419
! > Print additional information if true.
418
420
logical , intent (in ) :: verbose
419
421
! > Error handling.
420
422
type (error_t), allocatable , intent (out ) :: error
421
423
422
- integer :: stat
423
- character (len= :), allocatable :: cmd_output, archive_format
424
+ integer :: stat,i
425
+ character (len= :), allocatable :: cmd_output, archive_format, add_files
424
426
425
427
call execute_and_read_output(' git archive -l' , cmd_output, error, verbose)
426
428
if (allocated (error)) return
@@ -431,7 +433,19 @@ subroutine git_archive(source, destination, ref, verbose, error)
431
433
call fatal_error(error, " Cannot find a suitable archive format for 'git archive'." ); return
432
434
end if
433
435
434
- call run(' git archive ' // ref// ' --format=' // archive_format// ' -o ' // destination, echo= verbose, exitstat= stat)
436
+ allocate (character (len= 0 ) :: add_files)
437
+ if (present (additional_files)) then
438
+ do i= 1 ,size (additional_files)
439
+ add_files = trim (add_files)// ' --add-file=' // adjustl (additional_files(i))
440
+ end do
441
+ endif
442
+
443
+ call run(' git archive ' // ref// ' &
444
+ --format=' // archive_format// &
445
+ add_files// ' \
446
+ -o ' // destination, \
447
+ echo= verbose, \
448
+ exitstat= stat)
435
449
if (stat /= 0 ) then
436
450
call fatal_error(error, " Error packing '" // source// " '." ); return
437
451
end if
0 commit comments