aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/git-format-patch.txt3
-rw-r--r--Documentation/glossary.txt6
-rw-r--r--diff.c3
-rw-r--r--sha1_file.c16
-rwxr-xr-xt/t4013-diff-various.sh2
-rw-r--r--t/t4013/diff.diff_--name-status_dir2_dir3
6 files changed, 29 insertions, 4 deletions
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index e5638102e..6cbcf937b 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -53,6 +53,9 @@ OPTIONS
-------
include::diff-options.txt[]
+-<n>::
+ Limits the number of patches to prepare.
+
-o|--output-directory <dir>::
Use <dir> to store the resulting files, instead of the
current working directory.
diff --git a/Documentation/glossary.txt b/Documentation/glossary.txt
index e903abfeb..3f7b1e42b 100644
--- a/Documentation/glossary.txt
+++ b/Documentation/glossary.txt
@@ -330,6 +330,12 @@ This commit is referred to as a "merge commit", or sometimes just a
denotes a particular <<def_object,object>>. These may be stored in
`$GIT_DIR/refs/`.
+[[def_reflog]]reflog::
+ A reflog shows the local "history" of a ref. In other words,
+ it can tell you what the 3rd last revision in _this_ repository
+ was, and what was the current state in _this_ repository,
+ yesterday 9:14pm. See gitlink:git-reflog[1] for details.
+
[[def_refspec]]refspec::
A "refspec" is used by <<def_fetch,fetch>> and
<<def_push,push>> to describe the mapping between remote
diff --git a/diff.c b/diff.c
index b6eb72be0..19589707c 100644
--- a/diff.c
+++ b/diff.c
@@ -2418,7 +2418,8 @@ static void diff_flush_raw(struct diff_filepair *p,
printf("%s ",
diff_unique_abbrev(p->two->sha1, abbrev));
}
- printf("%s%c%s", status, inter_name_termination, path_one);
+ printf("%s%c%s", status, inter_name_termination,
+ two_paths || p->one->mode ? path_one : path_two);
if (two_paths)
printf("%c%s", inter_name_termination, path_two);
putchar(line_termination);
diff --git a/sha1_file.c b/sha1_file.c
index f2b1ae032..1efd9ae19 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -352,10 +352,14 @@ static void read_info_alternates(const char * relative_base, int depth)
char *map;
size_t mapsz;
struct stat st;
- char path[PATH_MAX];
+ const char alt_file_name[] = "info/alternates";
+ /* Given that relative_base is no longer than PATH_MAX,
+ ensure that "path" has enough space to append "/", the
+ file name, "info/alternates", and a trailing NUL. */
+ char path[PATH_MAX + 1 + sizeof alt_file_name];
int fd;
- sprintf(path, "%s/info/alternates", relative_base);
+ sprintf(path, "%s/%s", relative_base, alt_file_name);
fd = open(path, O_RDONLY);
if (fd < 0)
return;
@@ -836,7 +840,10 @@ void install_packed_git(struct packed_git *pack)
static void prepare_packed_git_one(char *objdir, int local)
{
- char path[PATH_MAX];
+ /* Ensure that this buffer is large enough so that we can
+ append "/pack/" without clobbering the stack even if
+ strlen(objdir) were PATH_MAX. */
+ char path[PATH_MAX + 1 + 4 + 1 + 1];
int len;
DIR *dir;
struct dirent *de;
@@ -858,6 +865,9 @@ static void prepare_packed_git_one(char *objdir, int local)
if (!has_extension(de->d_name, ".idx"))
continue;
+ if (len + namelen + 1 > sizeof(path))
+ continue;
+
/* Don't reopen a pack we already have. */
strcpy(path + len, de->d_name);
for (p = packed_git; p; p = p->next) {
diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh
index b453b42af..9eec75422 100755
--- a/t/t4013-diff-various.sh
+++ b/t/t4013-diff-various.sh
@@ -17,6 +17,7 @@ test_expect_success setup '
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
mkdir dir &&
+ mkdir dir2 &&
for i in 1 2 3; do echo $i; done >file0 &&
for i in A B; do echo $i; done >dir/sub &&
cat file0 >file2 &&
@@ -254,6 +255,7 @@ diff --patch-with-stat initial..side
diff --patch-with-raw initial..side
diff --patch-with-stat -r initial..side
diff --patch-with-raw -r initial..side
+diff --name-status dir2 dir
EOF
test_done
diff --git a/t/t4013/diff.diff_--name-status_dir2_dir b/t/t4013/diff.diff_--name-status_dir2_dir
new file mode 100644
index 000000000..ef7fdb733
--- /dev/null
+++ b/t/t4013/diff.diff_--name-status_dir2_dir
@@ -0,0 +1,3 @@
+$ git diff --name-status dir2 dir
+A dir/sub
+$