Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Wed, 4 Jul 2007 05:56:59 +0000 (22:56 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Jul 2007 05:56:59 +0000 (22:56 -0700)
* maint:
Document -<n> for git-format-patch
glossary: add 'reflog'
diff --no-index: fix --name-status with added files
Don't smash stack when $GIT_ALTERNATE_OBJECT_DIRECTORIES is too long

Documentation/git-format-patch.txt
Documentation/glossary.txt
diff.c
sha1_file.c
t/t4013-diff-various.sh
t/t4013/diff.diff_--name-status_dir2_dir [new file with mode: 0644]
index e5638102ec50aba1550ed8ed1345666d601d3c94..6cbcf937bcd3128b27fbce673d8500590a3f66ce 100644 (file)
@@ -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.
index e903abfeb874f3d185bbf26e21b2ce529084b305..3f7b1e42b502e1cc87305167ffcb99486132caca 100644 (file)
@@ -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 b6eb72be029c9cd2f2b33977f3a3f02099b68106..19589707c4cf40e622b0f7b98b8fd07704b37c01 100644 (file)
--- 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);
index f2b1ae0325ea16e4e46152c3d3d2d3d7f2b32e3d..1efd9ae19a84dbc2765d4011ea06b2145e86ebb3 100644 (file)
@@ -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) {
index b453b42af7b0836d8c523352fe3b1f34e30f363e..9eec754221d85856613b01ec878ef4cb492aceb0 100755 (executable)
@@ -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 (file)
index 0000000..ef7fdb7
--- /dev/null
@@ -0,0 +1,3 @@
+$ git diff --name-status dir2 dir
+A      dir/sub
+$