Skip to content

Commit 179c94b

Browse files
committed
Merge branch 'maint-1.5.4' into maint
* maint-1.5.4: core-tutorial.txt: Fix showing the current behaviour. git-archive: ignore prefix when checking file attribute Fix documentation syntax of optional arguments in short options.
2 parents 1d2375d + abea85d commit 179c94b

File tree

7 files changed

+32
-15
lines changed

7 files changed

+32
-15
lines changed

Documentation/core-tutorial.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,18 +535,18 @@ with the associated patches use the more complex (and much more
535535
powerful)
536536

537537
----------------
538-
$ git-whatchanged -p --root
538+
$ git-whatchanged -p
539539
----------------
540540

541541
and you will see exactly what has changed in the repository over its
542542
short history.
543543

544544
[NOTE]
545-
The `\--root` flag is a flag to `git-diff-tree` to tell it to
546-
show the initial aka 'root' commit too. Normally you'd probably not
547-
want to see the initial import diff, but since the tutorial project
548-
was started from scratch and is so small, we use it to make the result
549-
a bit more interesting.
545+
When using the above two commands, the initial commit will be shown.
546+
If this is a problem because it is huge, you can hide it by setting
547+
the log.showroot configuration variable to false. Having this, you
548+
can still show it for each command just adding the `\--root` option,
549+
which is a flag for `git-diff-tree` accepted by both commands.
550550

551551
With that, you should now be having some inkling of what git does, and
552552
can explore on your own.

Documentation/git-tag.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SYNOPSIS
1111
[verse]
1212
'git-tag' [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] <name> [<head>]
1313
'git-tag' -d <name>...
14-
'git-tag' [-n [<num>]] -l [<pattern>]
14+
'git-tag' [-n[<num>]] -l [<pattern>]
1515
'git-tag' -v <name>...
1616

1717
DESCRIPTION
@@ -57,7 +57,7 @@ OPTIONS
5757
-v::
5858
Verify the gpg signature of the given tag names.
5959

60-
-n <num>::
60+
-n<num>::
6161
<num> specifies how many lines from the annotation, if any,
6262
are printed when using -l.
6363
The default is not to print any annotation lines.

archive-tar.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ static time_t archive_time;
1717
static int tar_umask = 002;
1818
static int verbose;
1919
static const struct commit *commit;
20+
static size_t base_len;
2021

2122
/* writes out the whole block, but only if it is full */
2223
static void write_if_needed(void)
@@ -251,8 +252,8 @@ static int write_tar_entry(const unsigned char *sha1,
251252
buffer = NULL;
252253
size = 0;
253254
} else {
254-
buffer = sha1_file_to_archive(path.buf, sha1, mode, &type,
255-
&size, commit);
255+
buffer = sha1_file_to_archive(path.buf + base_len, sha1, mode,
256+
&type, &size, commit);
256257
if (!buffer)
257258
die("cannot read %s", sha1_to_hex(sha1));
258259
}
@@ -272,6 +273,7 @@ int write_tar_archive(struct archiver_args *args)
272273
archive_time = args->time;
273274
verbose = args->verbose;
274275
commit = args->commit;
276+
base_len = args->base ? strlen(args->base) : 0;
275277

276278
if (args->commit_sha1)
277279
write_global_extended_header(args->commit_sha1);

archive-zip.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ static int verbose;
1313
static int zip_date;
1414
static int zip_time;
1515
static const struct commit *commit;
16+
static size_t base_len;
1617

1718
static unsigned char *zip_dir;
1819
static unsigned int zip_dir_size;
@@ -197,8 +198,8 @@ static int write_zip_entry(const unsigned char *sha1,
197198
if (S_ISREG(mode) && zlib_compression_level != 0)
198199
method = 8;
199200
result = 0;
200-
buffer = sha1_file_to_archive(path, sha1, mode, &type, &size,
201-
commit);
201+
buffer = sha1_file_to_archive(path + base_len, sha1, mode,
202+
&type, &size, commit);
202203
if (!buffer)
203204
die("cannot read %s", sha1_to_hex(sha1));
204205
crc = crc32(crc, buffer, size);
@@ -321,6 +322,7 @@ int write_zip_archive(struct archiver_args *args)
321322
zip_dir_size = ZIP_DIRECTORY_MIN_SIZE;
322323
verbose = args->verbose;
323324
commit = args->commit;
325+
base_len = args->base ? strlen(args->base) : 0;
324326

325327
if (args->base && plen > 0 && args->base[plen - 1] == '/') {
326328
char *base = xstrdup(args->base);

builtin-tag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
static const char * const git_tag_usage[] = {
1717
"git-tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]",
1818
"git-tag -d <tagname>...",
19-
"git-tag -l [-n [<num>]] [<pattern>]",
19+
"git-tag -l [-n[<num>]] [<pattern>]",
2020
"git-tag -v <tagname>...",
2121
NULL
2222
};

parse-options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ void usage_with_options_internal(const char * const *usagestr,
344344
break;
345345
case OPTION_INTEGER:
346346
if (opts->flags & PARSE_OPT_OPTARG)
347-
pos += fprintf(stderr, " [<n>]");
347+
pos += fprintf(stderr, "[<n>]");
348348
else
349349
pos += fprintf(stderr, " <n>");
350350
break;

t/t5000-tar-tree.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,10 @@ test_expect_success \
109109
'diff -r a c/prefix/a'
110110

111111
test_expect_success \
112-
'create an archive with a substfiles' \
112+
'create archives with substfiles' \
113113
'echo "substfile?" export-subst >a/.gitattributes &&
114114
git archive HEAD >f.tar &&
115+
git archive --prefix=prefix/ HEAD >g.tar &&
115116
rm a/.gitattributes'
116117

117118
test_expect_success \
@@ -126,6 +127,18 @@ test_expect_success \
126127
diff a/substfile2 f/a/substfile2
127128
'
128129

130+
test_expect_success \
131+
'extract substfiles from archive with prefix' \
132+
'(mkdir g && cd g && $TAR xf -) <g.tar'
133+
134+
test_expect_success \
135+
'validate substfile contents from archive with prefix' \
136+
'git log --max-count=1 "--pretty=format:A${SUBSTFORMAT}O" HEAD \
137+
>g/prefix/a/substfile1.expected &&
138+
diff g/prefix/a/substfile1.expected g/prefix/a/substfile1 &&
139+
diff a/substfile2 g/prefix/a/substfile2
140+
'
141+
129142
test_expect_success \
130143
'git archive --format=zip' \
131144
'git archive --format=zip HEAD >d.zip'

0 commit comments

Comments
 (0)