Skip to content

Commit

Permalink
Merge branch 'maint'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed Jul 4, 2007
2 parents f6b78c6 + ed5f07a commit e2b1acc
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Documentation/git-format-patch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions Documentation/glossary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 13 additions & 3 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions t/t4013-diff-various.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions t/t4013/diff.diff_--name-status_dir2_dir
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ git diff --name-status dir2 dir
A dir/sub
$

0 comments on commit e2b1acc

Please sign in to comment.