archive: improve documentation of --prefix

Document the interaction between --add-file and --prefix by giving an example. Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed May 28, 2022 at 08:57 UTC a75910602a7367281409c4f13b5b87f350a0dc43
1 file changed +12 -4
Documentation/git-archive.txt
+12 -4
@@ -49,7 +49,9 @@ OPTIONS
49 Report progress to stderr.
50
51 --prefix=<prefix>/::
52 - Prepend <prefix>/ to each filename in the archive.
52 + Prepend <prefix>/ to paths in the archive. Can be repeated; its
53 + rightmost value is used for all tracked files. See below which
54 + value gets used by `--add-file`.
55
56 -o <file>::
57 --output=<file>::
@@ -57,9 +59,9 @@ OPTIONS
59
60 --add-file=<file>::
61 Add a non-tracked file to the archive. Can be repeated to add
60 - multiple files. The path of the file in the archive is built
61 - by concatenating the value for `--prefix` (if any) and the
62 - basename of <file>.
62 + multiple files. The path of the file in the archive is built by
63 + concatenating the value of the last `--prefix` option (if any)
64 + before this `--add-file` and the basename of <file>.
65
66 --worktree-attributes::
67 Look for attributes in .gitattributes files in the working tree
@@ -194,6 +196,12 @@ EXAMPLES
196 commit on the current branch. Note that the output format is
197 inferred by the extension of the output file.
198
199 +`git archive -o latest.tar --prefix=build/ --add-file=configure --prefix= HEAD`::
200 +
201 + Creates a tar archive that contains the contents of the latest
202 + commit on the current branch with no prefix and the untracked
203 + file 'configure' with the prefix 'build/'.
204 +
205 `git config tar.tar.xz.command "xz -c"`::
206
207 Configure a "tar.xz" format for making LZMA-compressed tarfiles.