Skip to content

Commit

Permalink
Merge branch 'jc/test-clone' into jc/clone
Browse files Browse the repository at this point in the history
* jc/test-clone: (35 commits)
  Introduce GIT_TEMPLATE_DIR
  Revert "fix testsuite: make sure they use templates freshly built from the source"
  fix testsuite: make sure they use templates freshly built from the source
  rerere: fix breakage of resolving.
  Add config example with respect to branch
  Add documentation for show-branch --topics
  make git a bit less cryptic on fetch errors
  make patch_delta() error cases a bit more verbose
  racy-git: documentation updates.
  show-ref: fix --exclude-existing
  parse-remote::expand_refs_wildcard()
  vim syntax: follow recent changes to commit template
  show-ref: fix --verify --hash=length
  show-ref: fix --quiet --verify
  avoid accessing _all_ loose refs in git-show-ref --verify
  git-fetch: Avoid reading packed refs over and over again
  Teach show-branch how to show ref-log data.
  markup fix in svnimport documentation.
  Documentation: new option -P for git-svnimport
  Fix mis-mark-up in git-merge-file.txt documentation
  ...
  • Loading branch information
Junio C Hamano committed Dec 19, 2006
2 parents 63085fa + 8683a45 commit 5fed466
Show file tree
Hide file tree
Showing 29 changed files with 564 additions and 106 deletions.
5 changes: 5 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ Example
external = "/usr/local/bin/gnu-diff -u"
renames = true

[branch "devel"]
remote = origin
merge = refs/heads/devel


Variables
~~~~~~~~~

Expand Down
4 changes: 2 additions & 2 deletions Documentation/git-merge-file.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
git-merge-file(1)
============
=================

NAME
----
git-merge-file - threeway file merge
git-merge-file - three-way file merge


SYNOPSIS
Expand Down
10 changes: 9 additions & 1 deletion Documentation/git-show-branch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SYNOPSIS
[verse]
'git-show-branch' [--all] [--heads] [--tags] [--topo-order] [--current]
[--more=<n> | --list | --independent | --merge-base]
[--no-name | --sha1-name] [<rev> | <glob>]...
[--no-name | --sha1-name] [--topics] [<rev> | <glob>]...

DESCRIPTION
-----------
Expand Down Expand Up @@ -86,6 +86,14 @@ OPTIONS
of "master"), name them with the unique prefix of their
object names.

--topics::
Shows only commits that are NOT on the first branch given.
This helps track topic branches by hiding any commit that
is already in the main line of development. When given
"git show-branch --topics master topic1 topic2", this
will show the revisions given by "git rev-list {caret}master
topic1 topic2"

Note that --more, --list, --independent and --merge-base options
are mutually exclusive.

Expand Down
13 changes: 11 additions & 2 deletions Documentation/git-svnimport.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ SYNOPSIS
[ -b branch_subdir ] [ -T trunk_subdir ] [ -t tag_subdir ]
[ -s start_chg ] [ -m ] [ -r ] [ -M regex ]
[ -I <ignorefile_name> ] [ -A <author_file> ]
[ -P <path_from_trunk> ]
<SVN_repository_URL> [ <path> ]


Expand Down Expand Up @@ -103,9 +104,17 @@ repository without -A.

-l <max_rev>::
Specify a maximum revision number to pull.
+
Formerly, this option controlled how many revisions to pull,
due to SVN memory leaks. (These have been worked around.)

Formerly, this option controlled how many revisions to pull,
due to SVN memory leaks. (These have been worked around.)
-P <path_from_trunk>::
Partial import of the SVN tree.
+
By default, the whole tree on the SVN trunk (/trunk) is imported.
'-P my/proj' will import starting only from '/trunk/my/proj'.
This option is useful when you want to import one project from a
svn repo which hosts multiple projects under the same trunk.

-v::
Verbosity: let 'svnimport' report what it is doing.
Expand Down
38 changes: 20 additions & 18 deletions Documentation/technical/racy-git.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Use of index and Racy git problem
Background
----------

The index is one of the most important data structure in git.
The index is one of the most important data structures in git.
It represents a virtual working tree state by recording list of
paths and their object names and serves as a staging area to
write out the next tree object to be committed. The state is
Expand All @@ -16,17 +16,17 @@ virtual working tree state in the index and the files in the
working tree. The most obvious case is when the user asks `git
diff` (or its low level implementation, `git diff-files`) or
`git-ls-files --modified`. In addition, git internally checks
if the files in the working tree is different from what are
if the files in the working tree are different from what are
recorded in the index to avoid stomping on local changes in them
during patch application, switching branches, and merging.

In order to speed up this comparison between the files in the
working tree and the index entries, the index entries record the
information obtained from the filesystem via `lstat(2)` system
call when they were last updated. When checking if they differ,
git first runs `lstat(2)` on the files and compare the result
git first runs `lstat(2)` on the files and compares the result
with this information (this is what was originally done by the
`ce_match_stat()` function, which the current code does in
`ce_match_stat()` function, but the current code does it in
`ce_match_stat_basic()` function). If some of these "cached
stat information" fields do not match, git can tell that the
files are modified without even looking at their contents.
Expand All @@ -53,16 +53,18 @@ Racy git
There is one slight problem with the optimization based on the
cached stat information. Consider this sequence:

: modify 'foo'
$ git update-index 'foo'
: modify 'foo' in-place without changing its size
: modify 'foo' again, in-place, without changing its size

The first `update-index` computes the object name of the
contents of file `foo` and updates the index entry for `foo`
along with the `struct stat` information. If the modification
that follows it happens very fast so that the file's `st_mtime`
timestamp does not change, after this sequence, the cached stat
information the index entry records still exactly match what you
can obtain from the filesystem, but the file `foo` is modified.
would see in the filesystem, even though the file `foo` is now
different.
This way, git can incorrectly think files in the working tree
are unmodified even though they actually are. This is called
the "racy git" problem (discovered by Pasky), and the entries
Expand All @@ -87,7 +89,7 @@ the stat information from updated paths, `st_mtime` timestamp of
it is usually the same as or newer than any of the paths the
index contains. And no matter how quick the modification that
follows `git update-index foo` finishes, the resulting
`st_mtime` timestamp on `foo` cannot get the timestamp earlier
`st_mtime` timestamp on `foo` cannot get a value earlier
than the index file. Therefore, index entries that can be
racily clean are limited to the ones that have the same
timestamp as the index file itself.
Expand All @@ -111,7 +113,7 @@ value, and falsely clean entry `foo` would not be caught by the
timestamp comparison check done with the former logic anymore.
The latter makes sure that the cached stat information for `foo`
would never match with the file in the working tree, so later
checks by `ce_match_stat_basic()` would report the index entry
checks by `ce_match_stat_basic()` would report that the index entry
does not match the file and git does not have to fall back on more
expensive `ce_modified_check_fs()`.

Expand Down Expand Up @@ -155,17 +157,16 @@ of the cached stat information.
Avoiding runtime penalty
------------------------

In order to avoid the above runtime penalty, the recent "master"
branch (post 1.4.2) has a code that makes sure the index file
gets timestamp newer than the youngest files in the index when
In order to avoid the above runtime penalty, post 1.4.2 git used
to have a code that made sure the index file
got timestamp newer than the youngest files in the index when
there are many young files with the same timestamp as the
resulting index file would otherwise would have by waiting
before finishing writing the index file out.

I suspect that in practice the situation where many paths in the
index are all racily clean is quite rare. The only code paths
that can record recent timestamp for large number of paths I
know of are:
I suspected that in practice the situation where many paths in the
index are all racily clean was quite rare. The only code paths
that can record recent timestamp for large number of paths are:

. Initial `git add .` of a large project.

Expand All @@ -188,6 +189,7 @@ youngest file in the working tree. This means that in these
cases there actually will not be any racily clean entry in
the resulting index.

So in summary I think we should not worry about avoiding the
runtime penalty and get rid of the "wait before finishing
writing" code out.
Based on this discussion, the current code does not use the
"workaround" to avoid the runtime penalty that does not exist in
practice anymore. This was done with commit 0fc82cff on Aug 15,
2006.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,8 @@ test: all
test-date$X: test-date.c date.o ctype.o
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) test-date.c date.o ctype.o

test-delta$X: test-delta.c diff-delta.o patch-delta.o
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $^
test-delta$X: test-delta.o diff-delta.o patch-delta.o $(GITLIBS)
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)

test-dump-cache-tree$X: dump-cache-tree.o $(GITLIBS)
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
Expand Down
15 changes: 14 additions & 1 deletion builtin-blame.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,11 @@ static void assign_blame(struct scoreboard *sb, struct rev_info *revs, int opt)
if (!(commit->object.flags & UNINTERESTING) &&
!(revs->max_age != -1 && commit->date < revs->max_age))
pass_blame(sb, suspect, opt);
else {
commit->object.flags |= UNINTERESTING;
if (commit->object.parsed)
mark_parents_uninteresting(commit);
}

/* Take responsibility for the remaining entries */
for (ent = sb->ent; ent; ent = ent->next)
Expand Down Expand Up @@ -1273,6 +1278,8 @@ static void emit_porcelain(struct scoreboard *sb, struct blame_entry *ent)
printf("committer-tz %s\n", ci.committer_tz);
printf("filename %s\n", suspect->path);
printf("summary %s\n", ci.summary);
if (suspect->commit->object.flags & UNINTERESTING)
printf("boundary\n");
}
else if (suspect->commit->object.flags & MORE_THAN_ONE_PATH)
printf("filename %s\n", suspect->path);
Expand Down Expand Up @@ -1308,8 +1315,14 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
cp = nth_line(sb, ent->lno);
for (cnt = 0; cnt < ent->num_lines; cnt++) {
char ch;
int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? 40 : 8;

if (suspect->commit->object.flags & UNINTERESTING) {
length--;
putchar('^');
}

printf("%.*s", (opt & OUTPUT_LONG_OBJECT_NAME) ? 40 : 8, hex);
printf("%.*s", length, hex);
if (opt & OUTPUT_ANNOTATE_COMPAT)
printf("\t(%10s\t%10s\t%d)", ci.author,
format_time(ci.author_time, ci.author_tz,
Expand Down
7 changes: 5 additions & 2 deletions builtin-init-db.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ static void copy_templates(const char *git_dir, int len, const char *template_di
int template_len;
DIR *dir;

if (!template_dir)
template_dir = DEFAULT_GIT_TEMPLATE_DIR;
if (!template_dir) {
template_dir = getenv("GIT_TEMPLATE_DIR");
if (!template_dir)
template_dir = DEFAULT_GIT_TEMPLATE_DIR;
}
strcpy(template_path, template_dir);
template_len = strlen(template_path);
if (template_path[template_len-1] != '/') {
Expand Down
14 changes: 13 additions & 1 deletion builtin-repo-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <regex.h>

static const char git_config_set_usage[] =
"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --list";
"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --list";

static char *key;
static regex_t *key_regexp;
Expand Down Expand Up @@ -148,6 +148,18 @@ int cmd_repo_config(int argc, const char **argv, const char *prefix)
} else {
die("$HOME not set");
}
} else if (!strcmp(argv[1], "--rename-section")) {
int ret;
if (argc != 4)
usage(git_config_set_usage);
ret = git_config_rename_section(argv[2], argv[3]);
if (ret < 0)
return ret;
if (ret == 0) {
fprintf(stderr, "No such section!\n");
return 1;
}
return 0;
} else
break;
argc--;
Expand Down
35 changes: 30 additions & 5 deletions builtin-show-branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "builtin.h"

static const char show_branch_usage[] =
"git-show-branch [--sparse] [--current] [--all] [--heads] [--tags] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [<refs>...]";
"git-show-branch [--sparse] [--current] [--all] [--heads] [--tags] [--topo-order] [--more=count | --list | --independent | --merge-base ] [--topics] [<refs>...] | --reflog[=n] <branch>";

static int default_num;
static int default_alloc;
Expand All @@ -17,6 +17,8 @@ static const char **default_arg;
#define REV_SHIFT 2
#define MAX_REVS (FLAG_BITS - REV_SHIFT) /* should not exceed bits_per_int - REV_SHIFT */

#define DEFAULT_REFLOG 4

static struct commit *interesting(struct commit_list *list)
{
while (list) {
Expand Down Expand Up @@ -570,6 +572,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
int head_at = -1;
int topics = 0;
int dense = 1;
int reflog = 0;

git_config(git_show_branch_config);

Expand Down Expand Up @@ -615,14 +618,23 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
dense = 0;
else if (!strcmp(arg, "--date-order"))
lifo = 0;
else if (!strcmp(arg, "--reflog")) {
reflog = DEFAULT_REFLOG;
}
else if (!strncmp(arg, "--reflog=", 9)) {
char *end;
reflog = strtoul(arg + 9, &end, 10);
if (*end != '\0')
die("unrecognized reflog count '%s'", arg + 9);
}
else
usage(show_branch_usage);
ac--; av++;
}
ac--; av++;

/* Only one of these is allowed */
if (1 < independent + merge_base + (extra != 0))
if (1 < independent + merge_base + (extra != 0) + (!!reflog))
usage(show_branch_usage);

/* If nothing is specified, show all branches by default */
Expand All @@ -631,9 +643,22 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)

if (all_heads + all_tags)
snarf_refs(all_heads, all_tags);
while (0 < ac) {
append_one_rev(*av);
ac--; av++;
if (reflog) {
int reflen;
if (!ac)
die("--reflog option needs one branch name");
reflen = strlen(*av);
for (i = 0; i < reflog; i++) {
char *name = xmalloc(reflen + 20);
sprintf(name, "%s@{%d}", *av, i);
append_one_rev(name);
}
}
else {
while (0 < ac) {
append_one_rev(*av);
ac--; av++;
}
}

head_p = resolve_ref("HEAD", head_sha1, 1, NULL);
Expand Down
Loading

0 comments on commit 5fed466

Please sign in to comment.