Skip to content

Commit bb79a82

Browse files
committed
Merge branch 'maint'
* maint: rev-parse: clarify documentation of $name@{upstream} syntax sha1_name: pass object name length to diagnose_invalid_sha1_path() Makefile: keep LIB_H entries together and sorted
2 parents 239222f + 47e329e commit bb79a82

File tree

3 files changed

+31
-38
lines changed

3 files changed

+31
-38
lines changed

Documentation/revisions.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ some output processing may assume ref names in UTF-8.
8888
The construct '@\{-<n>\}' means the <n>th branch checked out
8989
before the current one.
9090

91-
'<refname>@\{upstream\}', e.g. 'master@\{upstream\}', '@\{u\}'::
92-
The suffix '@\{upstream\}' to a ref (short form '<refname>@\{u\}') refers to
93-
the branch the ref is set to build on top of. A missing ref defaults
94-
to the current branch.
91+
'<branchname>@\{upstream\}', e.g. 'master@\{upstream\}', '@\{u\}'::
92+
The suffix '@\{upstream\}' to a branchname (short form '<branchname>@\{u\}')
93+
refers to the branch that the branch specified by branchname is set to build on
94+
top of. A missing branchname defaults to the current one.
9595

9696
'<rev>{caret}', e.g. 'HEAD{caret}, v1.5.1{caret}0'::
9797
A suffix '{caret}' to a revision parameter means the first parent of

Makefile

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -617,22 +617,6 @@ LIB_FILE = libgit.a
617617
XDIFF_LIB = xdiff/lib.a
618618
VCSSVN_LIB = vcs-svn/lib.a
619619

620-
LIB_H += xdiff/xinclude.h
621-
LIB_H += xdiff/xmacros.h
622-
LIB_H += xdiff/xdiff.h
623-
LIB_H += xdiff/xtypes.h
624-
LIB_H += xdiff/xutils.h
625-
LIB_H += xdiff/xprepare.h
626-
LIB_H += xdiff/xdiffi.h
627-
LIB_H += xdiff/xemit.h
628-
629-
LIB_H += vcs-svn/line_buffer.h
630-
LIB_H += vcs-svn/sliding_window.h
631-
LIB_H += vcs-svn/repo_tree.h
632-
LIB_H += vcs-svn/fast_export.h
633-
LIB_H += vcs-svn/svndiff.h
634-
LIB_H += vcs-svn/svndump.h
635-
636620
GENERATED_H += common-cmds.h
637621

638622
LIB_H += advice.h
@@ -734,11 +718,24 @@ LIB_H += url.h
734718
LIB_H += userdiff.h
735719
LIB_H += utf8.h
736720
LIB_H += varint.h
721+
LIB_H += vcs-svn/fast_export.h
722+
LIB_H += vcs-svn/line_buffer.h
723+
LIB_H += vcs-svn/repo_tree.h
724+
LIB_H += vcs-svn/sliding_window.h
725+
LIB_H += vcs-svn/svndiff.h
726+
LIB_H += vcs-svn/svndump.h
737727
LIB_H += walker.h
738728
LIB_H += wildmatch.h
739729
LIB_H += wt-status.h
740730
LIB_H += xdiff-interface.h
741731
LIB_H += xdiff/xdiff.h
732+
LIB_H += xdiff/xdiffi.h
733+
LIB_H += xdiff/xemit.h
734+
LIB_H += xdiff/xinclude.h
735+
LIB_H += xdiff/xmacros.h
736+
LIB_H += xdiff/xprepare.h
737+
LIB_H += xdiff/xtypes.h
738+
LIB_H += xdiff/xutils.h
742739

743740
LIB_OBJS += abspath.o
744741
LIB_OBJS += advice.o

sha1_name.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,7 +1137,8 @@ int get_sha1_blob(const char *name, unsigned char *sha1)
11371137
static void diagnose_invalid_sha1_path(const char *prefix,
11381138
const char *filename,
11391139
const unsigned char *tree_sha1,
1140-
const char *object_name)
1140+
const char *object_name,
1141+
int object_name_len)
11411142
{
11421143
struct stat st;
11431144
unsigned char sha1[20];
@@ -1147,8 +1148,8 @@ static void diagnose_invalid_sha1_path(const char *prefix,
11471148
prefix = "";
11481149

11491150
if (!lstat(filename, &st))
1150-
die("Path '%s' exists on disk, but not in '%s'.",
1151-
filename, object_name);
1151+
die("Path '%s' exists on disk, but not in '%.*s'.",
1152+
filename, object_name_len, object_name);
11521153
if (errno == ENOENT || errno == ENOTDIR) {
11531154
char *fullname = xmalloc(strlen(filename)
11541155
+ strlen(prefix) + 1);
@@ -1158,16 +1159,16 @@ static void diagnose_invalid_sha1_path(const char *prefix,
11581159
if (!get_tree_entry(tree_sha1, fullname,
11591160
sha1, &mode)) {
11601161
die("Path '%s' exists, but not '%s'.\n"
1161-
"Did you mean '%s:%s' aka '%s:./%s'?",
1162+
"Did you mean '%.*s:%s' aka '%.*s:./%s'?",
11621163
fullname,
11631164
filename,
1164-
object_name,
1165+
object_name_len, object_name,
11651166
fullname,
1166-
object_name,
1167+
object_name_len, object_name,
11671168
filename);
11681169
}
1169-
die("Path '%s' does not exist in '%s'",
1170-
filename, object_name);
1170+
die("Path '%s' does not exist in '%.*s'",
1171+
filename, object_name_len, object_name);
11711172
}
11721173
}
11731174

@@ -1332,13 +1333,8 @@ static int get_sha1_with_context_1(const char *name,
13321333
}
13331334
if (*cp == ':') {
13341335
unsigned char tree_sha1[20];
1335-
char *object_name = NULL;
1336-
if (only_to_die) {
1337-
object_name = xmalloc(cp-name+1);
1338-
strncpy(object_name, name, cp-name);
1339-
object_name[cp-name] = '\0';
1340-
}
1341-
if (!get_sha1_1(name, cp-name, tree_sha1, GET_SHA1_TREEISH)) {
1336+
int len = cp - name;
1337+
if (!get_sha1_1(name, len, tree_sha1, GET_SHA1_TREEISH)) {
13421338
const char *filename = cp+1;
13431339
char *new_filename = NULL;
13441340

@@ -1348,8 +1344,8 @@ static int get_sha1_with_context_1(const char *name,
13481344
ret = get_tree_entry(tree_sha1, filename, sha1, &oc->mode);
13491345
if (ret && only_to_die) {
13501346
diagnose_invalid_sha1_path(prefix, filename,
1351-
tree_sha1, object_name);
1352-
free(object_name);
1347+
tree_sha1,
1348+
name, len);
13531349
}
13541350
hashcpy(oc->tree, tree_sha1);
13551351
strncpy(oc->path, filename,
@@ -1360,7 +1356,7 @@ static int get_sha1_with_context_1(const char *name,
13601356
return ret;
13611357
} else {
13621358
if (only_to_die)
1363-
die("Invalid object name '%s'.", object_name);
1359+
die("Invalid object name '%.*s'.", len, name);
13641360
}
13651361
}
13661362
return ret;

0 commit comments

Comments
 (0)