]> Pileus Git - ~andy/git/commitdiff
Merge branch 'jc/leftright'
authorJunio C Hamano <junkio@cox.net>
Wed, 20 Dec 2006 22:20:17 +0000 (14:20 -0800)
committerJunio C Hamano <junkio@cox.net>
Wed, 20 Dec 2006 22:20:17 +0000 (14:20 -0800)
* jc/leftright:
  Revert "Make left-right automatic."
  Make left-right automatic.
  Teach all of log family --left-right output.
  rev-list --left-right

101 files changed:
Documentation/config.txt
Documentation/git-clone.txt
Documentation/git-show-branch.txt
Documentation/technical/racy-git.txt
GIT-VERSION-GEN
Makefile
archive-tar.c
archive-zip.c
blob.c
builtin-add.c
builtin-apply.c
builtin-archive.c
builtin-blame.c
builtin-branch.c
builtin-for-each-ref.c
builtin-grep.c
builtin-init-db.c
builtin-log.c
builtin-ls-files.c
builtin-mailinfo.c
builtin-mailsplit.c
builtin-mv.c
builtin-name-rev.c
builtin-pack-objects.c
builtin-repo-config.c
builtin-runstatus.c
builtin-shortlog.c
builtin-show-branch.c
builtin-show-ref.c
builtin-stripspace.c
builtin-tar-tree.c
builtin-unpack-objects.c
builtin-upload-archive.c
cache.h
color.c
compat/inet_ntop.c
compat/mmap.c
compat/setenv.c
compat/strlcpy.c
compat/unsetenv.c
config.c
configure.ac
connect.c
contrib/vim/syntax/gitcommit.vim
convert-objects.c
daemon.c
date.c
diff-delta.c
diff.c
diffcore-order.c
diffcore-pickaxe.c
dir.c
entry.c
exec_cmd.c
fetch-pack.c
fetch.c
fsck-objects.c
git-clone.sh
git-compat-util.h
git-cvsserver.perl
git-fetch.sh
git-ls-remote.sh
git-parse-remote.sh
git-pull.sh
git-rerere.perl
git.c
gitweb/gitweb.perl
grep.c
help.c
ident.c
imap-send.c
index-pack.c
interpolate.c
lockfile.c
merge-base.c
merge-index.c
merge-recursive.c
patch-delta.c
path-list.c
path.c
pkt-line.c
receive-pack.c
refs.c
revision.c
rsh.c
run-command.c
sha1_file.c
ssh-upload.c
strbuf.c
t/t1300-repo-config.sh
t/t3200-branch.sh
t/t5510-fetch.sh
t/test-lib.sh
templates/remotes-- [deleted file]
test-date.c
test-delta.c
tree.c
unpack-trees.c
upload-pack.c
var.c
wt-status.c

index ceac54b024bd407f3c3d3079f6164b3d61401da3..22482d6a94e88544935eee5f560089b9a4bf0dfa 100644 (file)
@@ -31,6 +31,11 @@ Example
                external = "/usr/local/bin/gnu-diff -u"
                renames = true
 
+       [branch "devel"]
+               remote = origin
+               merge = refs/heads/devel
+
+
 Variables
 ~~~~~~~~~
 
index bfddb21fee0a73641dbbbb7efb1863f162851653..874934a33243106544181ffeae2fee8b03ff5e8d 100644 (file)
@@ -11,8 +11,7 @@ SYNOPSIS
 [verse]
 'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
          [-o <name>] [-u <upload-pack>] [--reference <repository>]
-         [--use-separate-remote | --no-separate-remote] <repository>
-         [<directory>]
+         <repository> [<directory>]
 
 DESCRIPTION
 -----------
@@ -99,18 +98,6 @@ OPTIONS
        if unset the templates are taken from the installation
        defined default, typically `/usr/share/git-core/templates`.
 
---use-separate-remote::
-       Save remotes heads under `$GIT_DIR/refs/remotes/origin/` instead
-       of `$GIT_DIR/refs/heads/`.  Only the local master branch is
-       saved in the latter. This is the default.
-
---no-separate-remote::
-       Save remotes heads in the same namespace as the local
-       heads, `$GIT_DIR/refs/heads/'.  In regular repositories,
-       this is a legacy setup git-clone created by default in
-       older Git versions, and will be removed before the next
-       major release.
-
 <repository>::
        The (possibly remote) repository to clone from.  It can
        be any URL git-fetch supports.
index a2445a48fc98ddd4865bab8d3033880a854fca36..948ff10e6c83b8842de453e798ff7916ac98d911 100644 (file)
@@ -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
 -----------
@@ -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.
 
index 7597d041420ab2e84fc607bc3c844824c4528491..5030d9f2f831651f231d5c40d0e2110564646ef2 100644 (file)
@@ -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
@@ -16,7 +16,7 @@ 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.
 
@@ -24,9 +24,9 @@ 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.
@@ -53,8 +53,9 @@ 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`
@@ -62,7 +63,8 @@ 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
@@ -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.
@@ -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()`.
 
@@ -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.
 
@@ -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.
index 4eac314f3a12b36c379fec139de6aecee5a0a2b6..eca1ff2175c9c62ce51fe6606d615f99925e7734 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=v1.4.4.1.GIT
+DEF_VER=v1.4.4.GIT
 
 LF='
 '
index 05cfe45b104d6860c3918f1c80596403ae73e5f7..76511045a80cf5da72851d8194742de56282d953 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -82,10 +82,6 @@ all:
 # Define NO_ACCURATE_DIFF if your diff program at least sometimes misses
 # a missing newline at the end of the file.
 #
-# Define COLLISION_CHECK below if you believe that SHA1's
-# 1461501637330902918203684832716283019655932542976 hashes do not give you
-# sufficient guarantee that no collisions between objects will ever happen.
-#
 # Define USE_NSEC below if you want git to care about sub-second file mtimes
 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
@@ -796,8 +792,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)
index ff0f6e29292cf716ac32e8ae63a58902fcccc120..af47fdc95572bfa67b9c67369222a69c32ddea02 100644 (file)
@@ -1,7 +1,6 @@
 /*
  * Copyright (c) 2005, 2006 Rene Scharfe
  */
-#include <time.h>
 #include "cache.h"
 #include "commit.h"
 #include "strbuf.h"
index 36e922a1f2ffe34264ac55c002072cb2777e7026..f31b8ed8236c3fcad10ac9a84e2f508f11e1a6cf 100644 (file)
@@ -1,7 +1,6 @@
 /*
  * Copyright (c) 2006 Rene Scharfe
  */
-#include <time.h>
 #include "cache.h"
 #include "commit.h"
 #include "blob.h"
diff --git a/blob.c b/blob.c
index d1af2e62f14965fab491a3d9dde712f02b718adc..9776beac5827a4c705eddde426817dcc40c525bc 100644 (file)
--- a/blob.c
+++ b/blob.c
@@ -1,6 +1,5 @@
 #include "cache.h"
 #include "blob.h"
-#include <stdlib.h>
 
 const char *blob_type = "blob";
 
index b3f920676a958e581c55dcca48e9a8f01b43859b..f306f82b16c3c3c76416610cd4cabf0a307924ed 100644 (file)
@@ -3,8 +3,6 @@
  *
  * Copyright (C) 2006 Linus Torvalds
  */
-#include <fnmatch.h>
-
 #include "cache.h"
 #include "builtin.h"
 #include "dir.h"
@@ -113,6 +111,11 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                }
                usage(builtin_add_usage);
        }
+       if (argc <= i) {
+               fprintf(stderr, "Nothing specified, nothing added.\n");
+               fprintf(stderr, "Maybe you wanted to say 'git add .'?\n");
+               return 0;
+       }
        pathspec = get_pathspec(prefix, argv + i);
 
        fill_directory(&dir, pathspec);
index 436d9e188070df0e4a51186716b033658a8672b5..1c3583706835339d2f3a0b0a5d3b989aae2a8142 100644 (file)
@@ -6,7 +6,6 @@
  * This applies patches on top of some (arbitrary) version of the SCM.
  *
  */
-#include <fnmatch.h>
 #include "cache.h"
 #include "cache-tree.h"
 #include "quote.h"
index a8a1f079bf4e28a3f07d49b6a4723ee8dea17178..391cf43911a16ec49862c18b7dd4f1f094d49de8 100644 (file)
@@ -2,7 +2,6 @@
  * Copyright (c) 2006 Franck Bui-Huu
  * Copyright (c) 2006 Rene Scharfe
  */
-#include <time.h>
 #include "cache.h"
 #include "builtin.h"
 #include "archive.h"
index dc3ffeaff82377262f0ae47993cf0883b2552092..4a1accf13c1220745c73999c6c345735aeadc3e5 100644 (file)
 #include "revision.h"
 #include "xdiff-interface.h"
 
-#include <time.h>
-#include <sys/time.h>
-#include <regex.h>
-
 static char blame_usage[] =
 "git-blame [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [commit] [--] file\n"
 "  -c, --compatibility Use the same output mode as git-annotate (Default: off)\n"
+"  -b                  Show blank SHA-1 for boundary commits (Default: off)\n"
 "  -l, --long          Show long commit SHA1 (Default: off)\n"
+"  --root              Do not treat root commits as boundaries (Default: off)\n"
 "  -t, --time          Show raw timestamp (Default: off)\n"
 "  -f, --show-name     Show original filename (Default: auto)\n"
 "  -n, --show-number   Show original linenumber (Default: off)\n"
@@ -36,6 +34,8 @@ static int longest_author;
 static int max_orig_digits;
 static int max_digits;
 static int max_score_digits;
+static int show_root;
+static int blank_boundary;
 
 #ifndef DEBUG
 #define DEBUG 0
@@ -1090,6 +1090,14 @@ 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);
+               }
+               /* treat root commit as boundary */
+               if (!commit->parents && !show_root)
+                       commit->object.flags |= UNINTERESTING;
 
                /* Take responsibility for the remaining entries */
                for (ent = sb->ent; ent; ent = ent->next)
@@ -1273,6 +1281,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);
@@ -1308,8 +1318,18 @@ 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) {
+                       if (!blank_boundary) {
+                               length--;
+                               putchar('^');
+                       }
+                       else
+                               memset(hex, ' ', length);
+               }
 
-               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,
@@ -1626,6 +1646,19 @@ static void prepare_blame_range(struct scoreboard *sb,
                usage(blame_usage);
 }
 
+static int git_blame_config(const char *var, const char *value)
+{
+       if (!strcmp(var, "blame.showroot")) {
+               show_root = git_config_bool(var, value);
+               return 0;
+       }
+       if (!strcmp(var, "blame.blankboundary")) {
+               blank_boundary = git_config_bool(var, value);
+               return 0;
+       }
+       return git_default_config(var, value);
+}
+
 int cmd_blame(int argc, const char **argv, const char *prefix)
 {
        struct rev_info revs;
@@ -1641,6 +1674,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
        char type[10];
        const char *bottomtop = NULL;
 
+       git_config(git_blame_config);
        save_commit_buffer = 0;
 
        opt = 0;
@@ -1649,6 +1683,10 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
                const char *arg = argv[i];
                if (*arg != '-')
                        break;
+               else if (!strcmp("-b", arg))
+                       blank_boundary = 1;
+               else if (!strcmp("--root", arg))
+                       show_root = 1;
                else if (!strcmp("-c", arg))
                        output_option |= OUTPUT_ANNOTATE_COMPAT;
                else if (!strcmp("-t", arg))
index 560309cb154504a8d280f12e3d9d2d3d6d715d7c..903d5cf05600f9a7e297dc9450ad5980388072e9 100644 (file)
@@ -5,15 +5,19 @@
  * Based on git-branch.sh by Junio C Hamano.
  */
 
-#include "color.h"
 #include "cache.h"
+#include "color.h"
 #include "refs.h"
 #include "commit.h"
 #include "builtin.h"
 
 static const char builtin_branch_usage[] =
-  "git-branch (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | (-m | -M) [<oldbranch>] <newbranch> | [-r | -a] [-v [--abbrev=<length>]]";
+  "git-branch [-r] (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | (-m | -M) [<oldbranch>] <newbranch> | [-r | -a] [-v [--abbrev=<length>]]";
 
+#define REF_UNKNOWN_TYPE    0x00
+#define REF_LOCAL_BRANCH    0x01
+#define REF_REMOTE_BRANCH   0x02
+#define REF_TAG             0x04
 
 static const char *head;
 static unsigned char head_sha1[20];
@@ -89,12 +93,28 @@ static int in_merge_bases(const unsigned char *sha1,
        return ret;
 }
 
-static void delete_branches(int argc, const char **argv, int force)
+static int delete_branches(int argc, const char **argv, int force, int kinds)
 {
        struct commit *rev, *head_rev = head_rev;
        unsigned char sha1[20];
-       char *name;
+       char *name = NULL;
+       const char *fmt, *remote;
        int i;
+       int ret = 0;
+
+       switch (kinds) {
+       case REF_REMOTE_BRANCH:
+               fmt = "refs/remotes/%s";
+               remote = "remote ";
+               force = 1;
+               break;
+       case REF_LOCAL_BRANCH:
+               fmt = "refs/heads/%s";
+               remote = "";
+               break;
+       default:
+               die("cannot use -a with -d");
+       }
 
        if (!force) {
                head_rev = lookup_commit_reference(head_sha1);
@@ -102,16 +122,30 @@ static void delete_branches(int argc, const char **argv, int force)
                        die("Couldn't look up commit object for HEAD");
        }
        for (i = 0; i < argc; i++) {
-               if (!strcmp(head, argv[i]))
-                       die("Cannot delete the branch you are currently on.");
+               if (kinds == REF_LOCAL_BRANCH && !strcmp(head, argv[i])) {
+                       error("Cannot delete the branch '%s' "
+                               "which you are currently on.", argv[i]);
+                       ret = 1;
+                       continue;
+               }
 
-               name = xstrdup(mkpath("refs/heads/%s", argv[i]));
-               if (!resolve_ref(name, sha1, 1, NULL))
-                       die("Branch '%s' not found.", argv[i]);
+               if (name)
+                       free(name);
+
+               name = xstrdup(mkpath(fmt, argv[i]));
+               if (!resolve_ref(name, sha1, 1, NULL)) {
+                       error("%sbranch '%s' not found.",
+                                       remote, argv[i]);
+                       ret = 1;
+                       continue;
+               }
 
                rev = lookup_commit_reference(sha1);
-               if (!rev)
-                       die("Couldn't look up commit object for '%s'", name);
+               if (!rev) {
+                       error("Couldn't look up commit object for '%s'", name);
+                       ret = 1;
+                       continue;
+               }
 
                /* This checks whether the merge bases of branch and
                 * HEAD contains branch -- which means that the HEAD
@@ -120,26 +154,28 @@ static void delete_branches(int argc, const char **argv, int force)
 
                if (!force &&
                    !in_merge_bases(sha1, rev, head_rev)) {
-                       fprintf(stderr,
-                               "The branch '%s' is not a strict subset of your current HEAD.\n"
-                               "If you are sure you want to delete it, run 'git branch -D %s'.\n",
-                               argv[i], argv[i]);
-                       exit(1);
+                       error("The branch '%s' is not a strict subset of "
+                               "your current HEAD.\n"
+                               "If you are sure you want to delete it, "
+                               "run 'git branch -D %s'.", argv[i], argv[i]);
+                       ret = 1;
+                       continue;
                }
 
-               if (delete_ref(name, sha1))
-                       printf("Error deleting branch '%s'\n", argv[i]);
-               else
-                       printf("Deleted branch %s.\n", argv[i]);
+               if (delete_ref(name, sha1)) {
+                       error("Error deleting %sbranch '%s'", remote,
+                              argv[i]);
+                       ret = 1;
+               } else
+                       printf("Deleted %sbranch %s.\n", remote, argv[i]);
 
-               free(name);
        }
-}
 
-#define REF_UNKNOWN_TYPE    0x00
-#define REF_LOCAL_BRANCH    0x01
-#define REF_REMOTE_BRANCH   0x02
-#define REF_TAG             0x04
+       if (name)
+               free(name);
+
+       return(ret);
+}
 
 struct ref_item {
        char *name;
@@ -435,7 +471,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
        head += 11;
 
        if (delete)
-               delete_branches(argc - i, argv + i, force_delete);
+               return delete_branches(argc - i, argv + i, force_delete, kinds);
        else if (i == argc)
                print_ref_list(kinds, verbose, abbrev);
        else if (rename && (i == argc - 1))
index 227aa3cd7f887ad44fd6b885479ef2afb586ded4..af72a12a5798265cece6c7b72582fd3672421394 100644 (file)
@@ -6,7 +6,6 @@
 #include "tree.h"
 #include "blob.h"
 #include "quote.h"
-#include <fnmatch.h>
 
 /* Quoting styles */
 #define QUOTE_NONE 0
index 9873e3d1dbf0e8735641cc178d687a9d5194487e..3b1b1cbbfa7bf348c17c025afa217ffff97087e3 100644 (file)
 #include "tag.h"
 #include "tree-walk.h"
 #include "builtin.h"
-#include <regex.h>
 #include "grep.h"
-#include <fnmatch.h>
-#include <sys/wait.h>
 
 /*
  * git grep pathspecs are somewhat different from diff-tree pathspecs;
index 1d7d15e8d53a7a2817ceff6f5c5e056747688c9e..01f366ad0bf5860aaf9123ef5d5653c612871a9f 100644 (file)
@@ -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(TEMPLATE_DIR_ENVIRONMENT);
+               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] != '/') {
index 17014f70a2896de46ff4714e77093b8adaa9fc8f..8df3c1394a0b70548708137bfe20126fbea01709 100644 (file)
@@ -11,8 +11,6 @@
 #include "log-tree.h"
 #include "builtin.h"
 #include "tag.h"
-#include <time.h>
-#include <sys/time.h>
 
 static int default_show_root = 1;
 
index bc79ce40fc87b7a77d22f2fea85f2198102fcb67..21c2a6e2d9b68c0c3bcfac824e85c7b392c72486 100644 (file)
@@ -5,8 +5,6 @@
  *
  * Copyright (C) Linus Torvalds, 2005
  */
-#include <fnmatch.h>
-
 #include "cache.h"
 #include "quote.h"
 #include "dir.h"
index b8d7dbc0b71929a95aaebd79d5912897d5eb70e7..e6472293d47611d415276f6057227d9c93788f63 100644 (file)
@@ -2,15 +2,6 @@
  * Another stupid program, this one parsing the headers of an
  * email to figure out authorship and subject
  */
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#ifndef NO_ICONV
-#include <iconv.h>
-#endif
-#include "git-compat-util.h"
 #include "cache.h"
 #include "builtin.h"
 
index 91a699d34d93462b56f2591193bb5729b42b3950..3bca855aae857cde15f2a249f8e0a5c30b3e7d82 100644 (file)
@@ -4,13 +4,6 @@
  * It just splits a mbox into a list of files: "0001" "0002" ..
  * so you can process them further from there.
  */
-#include <unistd.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <stdio.h>
 #include "cache.h"
 #include "builtin.h"
 
index d14a4a7f5c66c5f8712399d4b1fc566e0891125a..737af350b873e90c787cb49960236fc19b62a3bf 100644 (file)
@@ -3,8 +3,6 @@
  *
  * Copyright (C) 2006 Johannes Schindelin
  */
-#include <fnmatch.h>
-
 #include "cache.h"
 #include "builtin.h"
 #include "dir.h"
index 618aa314d22dd16bb62b0a7deb3be14fda411ebe..b4f15cc38ab7fa045fc5cf025ca3fd6251a01973 100644 (file)
@@ -1,4 +1,3 @@
-#include <stdlib.h>
 #include "builtin.h"
 #include "cache.h"
 #include "commit.h"
index a2dc7d1d9d39436e8e5266d1d4bb693b06a54b17..807be8c3f8a051d9171cf2ee3c9f973f77a2ff08 100644 (file)
@@ -12,8 +12,6 @@
 #include "diff.h"
 #include "revision.h"
 #include "list-objects.h"
-#include <sys/time.h>
-#include <signal.h>
 
 static const char pack_usage[] = "\
 git-pack-objects [{ -q | --progress | --all-progress }] \n\
index 64fbdb7b2420203cf1d142e73c5ec579c95cf581..90633119d4ae873ed30889e93dbb4307af0ae0d1 100644 (file)
@@ -1,9 +1,8 @@
 #include "builtin.h"
 #include "cache.h"
-#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;
@@ -67,10 +66,10 @@ static int get_value(const char* key_, const char* regex_)
        char *global = NULL, *repo_config = NULL;
        const char *local;
 
-       local = getenv("GIT_CONFIG");
+       local = getenv(CONFIG_ENVIRONMENT);
        if (!local) {
                const char *home = getenv("HOME");
-               local = getenv("GIT_CONFIG_LOCAL");
+               local = getenv(CONFIG_LOCAL_ENVIRONMENT);
                if (!local)
                        local = repo_config = xstrdup(git_path("config"));
                if (home)
@@ -148,6 +147,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--;
index 0b63037dd04e7c66d2e378ee394979cec040fe55..4b489b1214e1ae693a9b0b5166909800f5ca94ac 100644 (file)
@@ -1,5 +1,5 @@
-#include "wt-status.h"
 #include "cache.h"
+#include "wt-status.h"
 
 extern int wt_status_use_color;
 
index 3fc43dd7dd89fea2fb7f02e694ed632215002e13..edb40429ec4465f3bebba02f2174314dd0183225 100644 (file)
@@ -4,7 +4,6 @@
 #include "diff.h"
 #include "path-list.h"
 #include "revision.h"
-#include <string.h>
 
 static const char shortlog_usage[] =
 "git-shortlog [-n] [-s] [<commit-id>... ]";
index fb1a4000d98e27389904578309b935cbda2a85fe..b9d9781d4d6a12860d377607369a4dea95a3c7be 100644 (file)
@@ -1,12 +1,10 @@
-#include <stdlib.h>
-#include <fnmatch.h>
 #include "cache.h"
 #include "commit.h"
 #include "refs.h"
 #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;
@@ -17,6 +15,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) {
@@ -570,6 +570,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);
 
@@ -615,6 +616,15 @@ 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++;
@@ -622,7 +632,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
        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 */
@@ -631,9 +641,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);
index 073979855b30b72363ed8116288b7bbbb2f0ff74..853f13f6ae9df60e340a6988a9d74bb246df4df6 100644 (file)
@@ -2,13 +2,23 @@
 #include "refs.h"
 #include "object.h"
 #include "tag.h"
+#include "path-list.h"
 
-static const char show_ref_usage[] = "git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=<length>]] [--abbrev[=<length>]] [--tags] [--heads] [--] [pattern*]";
+static const char show_ref_usage[] = "git show-ref [-q|--quiet] [--verify] [-h|--head] [-d|--dereference] [-s|--hash[=<length>]] [--abbrev[=<length>]] [--tags] [--heads] [--] [pattern*] < ref-list";
 
 static int deref_tags = 0, show_head = 0, tags_only = 0, heads_only = 0,
        found_match = 0, verify = 0, quiet = 0, hash_only = 0, abbrev = 0;
 static const char **pattern;
 
+static void show_one(const char *refname, const unsigned char *sha1)
+{
+       const char *hex = find_unique_abbrev(sha1, abbrev);
+       if (hash_only)
+               printf("%s\n", hex);
+       else
+               printf("%s %s\n", hex, refname);
+}
+
 static int show_ref(const char *refname, const unsigned char *sha1, int flag, void *cbdata)
 {
        struct object *obj;
@@ -57,11 +67,7 @@ match:
        if (quiet)
                return 0;
 
-       hex = find_unique_abbrev(sha1, abbrev);
-       if (hash_only)
-               printf("%s\n", hex);
-       else
-               printf("%s %s\n", hex, refname);
+       show_one(refname, sha1);
 
        if (!deref_tags)
                return 0;
@@ -86,6 +92,60 @@ match:
        return 0;
 }
 
+static int add_existing(const char *refname, const unsigned char *sha1, int flag, void *cbdata)
+{
+       struct path_list *list = (struct path_list *)cbdata;
+       path_list_insert(refname, list);
+       return 0;
+}
+
+/*
+ * read "^(?:<anything>\s)?<refname>(?:\^\{\})?$" from the standard input,
+ * and
+ * (1) strip "^{}" at the end of line if any;
+ * (2) ignore if match is provided and does not head-match refname;
+ * (3) warn if refname is not a well-formed refname and skip;
+ * (4) ignore if refname is a ref that exists in the local repository;
+ * (5) otherwise output the line.
+ */
+static int exclude_existing(const char *match)
+{
+       static struct path_list existing_refs = { NULL, 0, 0, 0 };
+       char buf[1024];
+       int matchlen = match ? strlen(match) : 0;
+
+       for_each_ref(add_existing, &existing_refs);
+       while (fgets(buf, sizeof(buf), stdin)) {
+               char *ref;
+               int len = strlen(buf);
+
+               if (len > 0 && buf[len - 1] == '\n')
+                       buf[--len] = '\0';
+               if (3 <= len && !strcmp(buf + len - 3, "^{}")) {
+                       len -= 3;
+                       buf[len] = '\0';
+               }
+               for (ref = buf + len; buf < ref; ref--)
+                       if (isspace(ref[-1]))
+                               break;
+               if (match) {
+                       int reflen = buf + len - ref;
+                       if (reflen < matchlen)
+                               continue;
+                       if (strncmp(ref, match, matchlen))
+                               continue;
+               }
+               if (check_ref_format(ref)) {
+                       fprintf(stderr, "warning: ref '%s' ignored\n", ref);
+                       continue;
+               }
+               if (!path_list_has_path(&existing_refs, ref)) {
+                       printf("%s\n", buf);
+               }
+       }
+       return 0;
+}
+
 int cmd_show_ref(int argc, const char **argv, const char *prefix)
 {
        int i;
@@ -121,13 +181,13 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
                if (!strncmp(arg, "--hash=", 7) ||
                    (!strncmp(arg, "--abbrev", 8) &&
                     (arg[8] == '=' || arg[8] == '\0'))) {
-                       if (arg[3] != 'h' && !arg[8])
+                       if (arg[2] != 'h' && !arg[8])
                                /* --abbrev only */
                                abbrev = DEFAULT_ABBREV;
                        else {
                                /* --hash= or --abbrev= */
                                char *end;
-                               if (arg[3] == 'h') {
+                               if (arg[2] == 'h') {
                                        hash_only = 1;
                                        arg += 7;
                                }
@@ -153,8 +213,31 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix)
                        heads_only = 1;
                        continue;
                }
+               if (!strcmp(arg, "--exclude-existing"))
+                       return exclude_existing(NULL);
+               if (!strncmp(arg, "--exclude-existing=", 19))
+                       return exclude_existing(arg + 19);
                usage(show_ref_usage);
        }
+
+       if (verify) {
+               unsigned char sha1[20];
+
+               while (*pattern) {
+                       if (!strncmp(*pattern, "refs/", 5) &&
+                           resolve_ref(*pattern, sha1, 1, NULL)) {
+                               if (!quiet)
+                                       show_one(*pattern, sha1);
+                       }
+                       else if (!quiet)
+                               die("'%s' - not a valid ref", *pattern);
+                       else
+                               return 1;
+                       pattern++;
+               }
+               return 0;
+       }
+
        if (show_head)
                head_ref(show_ref, NULL);
        for_each_ref(show_ref, NULL);
index 09cc9108cdaf2aa20dc10788bccd2fee0ae9b02a..f0d4d9e2d10446a229094c991363f5a17ce4c666 100644 (file)
@@ -1,6 +1,3 @@
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
 #include "builtin.h"
 
 /*
index 4d4cfec878e468b8ab8a7f055c836c3569443914..11e62fc141f592977373630c7671d3e7e914c314 100644 (file)
@@ -1,7 +1,6 @@
 /*
  * Copyright (c) 2005, 2006 Rene Scharfe
  */
-#include <time.h>
 #include "cache.h"
 #include "commit.h"
 #include "tar.h"
index e6d75748444ef4fc263970d4fe87b4623d2790fc..d351e02649401364e7384d0e784901e6f3fcb119 100644 (file)
@@ -8,8 +8,6 @@
 #include "tag.h"
 #include "tree.h"
 
-#include <sys/time.h>
-
 static int dry_run, quiet, recover, has_errors;
 static const char unpack_usage[] = "git-unpack-objects [-n] [-q] [-r] < pack-file";
 
index 45c92e163c477af4ec7c36c8ee6fcfd9242a0b2d..e4156f8f48aeed307b1754bada173034dd81a311 100644 (file)
@@ -1,9 +1,6 @@
 /*
  * Copyright (c) 2006 Franck Bui-Huu
  */
-#include <time.h>
-#include <sys/wait.h>
-#include <sys/poll.h>
 #include "cache.h"
 #include "builtin.h"
 #include "archive.h"
diff --git a/cache.h b/cache.h
index b540292d669165cf144f3848e54f7494c1d37ad4..4943056c19ffb72a7cfb994daaa788ec1b01d60b 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -122,6 +122,10 @@ extern int cache_errno;
 #define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
 #define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
 #define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
+#define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR"
+#define CONFIG_ENVIRONMENT "GIT_CONFIG"
+#define CONFIG_LOCAL_ENVIRONMENT "GIT_CONFIG_LOCAL"
+#define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
 
 extern int is_bare_git_dir(const char *dir);
 extern const char *get_git_dir(void);
@@ -405,6 +409,7 @@ extern int git_config_int(const char *, const char *);
 extern int git_config_bool(const char *, const char *);
 extern int git_config_set(const char *, const char *);
 extern int git_config_set_multivar(const char *, const char *, const char *, int);
+extern int git_config_rename_section(const char *, const char *);
 extern int check_repository_format_version(const char *var, const char *value);
 
 #define MAX_GITNAME (1000)
diff --git a/color.c b/color.c
index d8c8399d5916432eaa4122175f5e5d7ce209001b..09d82eec3d0adf5b7bd8828b0c8df0554695f75c 100644 (file)
--- a/color.c
+++ b/color.c
@@ -1,8 +1,5 @@
-#include "color.h"
 #include "cache.h"
-#include "git-compat-util.h"
-
-#include <stdarg.h>
+#include "color.h"
 
 #define COLOR_RESET "\033[m"
 
index ec8c1bff539232c581fd10ef1d01c345442a2e35..4d7ab9d9758428c003a74d9f85699d7fc6922e05 100644 (file)
@@ -93,7 +93,7 @@ inet_ntop6(src, dst, size)
         */
        char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
        struct { int base, len; } best, cur;
-       u_int words[NS_IN6ADDRSZ / NS_INT16SZ];
+       unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
        int i;
 
        /*
index a4d2e507f73c5595a2ca76c0369349cc11e2426f..0fd46e793d088e6567b20c7e81a5cde7023bdb58 100644 (file)
@@ -1,7 +1,3 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
 #include "../git-compat-util.h"
 
 void *gitfakemmap(void *start, size_t length, int prot , int flags, int fd, off_t offset)
index b7d76785980b81a6f1057d678d34a732f45ca4cd..3a22ea7b751efb768d72afa2f97fd963e10eec7e 100644 (file)
@@ -1,5 +1,4 @@
-#include <stdlib.h>
-#include <string.h>
+#include "../git-compat-util.h"
 
 int gitsetenv(const char *name, const char *value, int replace)
 {
index b66856a3a50a93262ee4b5bd0294bb0c7fc85b15..4024c360301ebe7d58ac5b84dcbb692341b649ed 100644 (file)
@@ -1,4 +1,4 @@
-#include <string.h>
+#include "../git-compat-util.h"
 
 size_t gitstrlcpy(char *dest, const char *src, size_t size)
 {
index 3a5e4ec04ae4a523823e633031b85559bf5dc973..eb29f5e0849370afe90c400271fea12e0f9090aa 100644 (file)
@@ -1,5 +1,4 @@
-#include <stdlib.h>
-#include <string.h>
+#include "../git-compat-util.h"
 
 void gitunsetenv (const char *name)
 {
index 1bdef44a3ad315ecc4cdfa879e9c0881bd82722b..1662a4626e569b07d96c622b357928216a24538c 100644 (file)
--- a/config.c
+++ b/config.c
@@ -6,7 +6,6 @@
  *
  */
 #include "cache.h"
-#include <regex.h>
 
 #define MAXNAME (256)
 
@@ -350,10 +349,10 @@ int git_config(config_fn_t fn)
         * $GIT_CONFIG_LOCAL will make it process it in addition to the
         * global config file, the same way it would the per-repository
         * config file otherwise. */
-       filename = getenv("GIT_CONFIG");
+       filename = getenv(CONFIG_ENVIRONMENT);
        if (!filename) {
                home = getenv("HOME");
-               filename = getenv("GIT_CONFIG_LOCAL");
+               filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
                if (!filename)
                        filename = repo_config = xstrdup(git_path("config"));
        }
@@ -544,9 +543,9 @@ int git_config_set_multivar(const char* key, const char* value,
        char* lock_file;
        const char* last_dot = strrchr(key, '.');
 
-       config_filename = getenv("GIT_CONFIG");
+       config_filename = getenv(CONFIG_ENVIRONMENT);
        if (!config_filename) {
-               config_filename = getenv("GIT_CONFIG_LOCAL");
+               config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
                if (!config_filename)
                        config_filename  = git_path("config");
        }
@@ -746,4 +745,75 @@ out_free:
        return ret;
 }
 
+int git_config_rename_section(const char *old_name, const char *new_name)
+{
+       int ret = 0;
+       char *config_filename;
+       struct lock_file *lock = xcalloc(sizeof(struct lock_file), 1);
+       int out_fd;
+       char buf[1024];
+
+       config_filename = getenv(CONFIG_ENVIRONMENT);
+       if (!config_filename) {
+               config_filename = getenv(CONFIG_LOCAL_ENVIRONMENT);
+               if (!config_filename)
+                       config_filename  = git_path("config");
+       }
+       config_filename = xstrdup(config_filename);
+       out_fd = hold_lock_file_for_update(lock, config_filename, 0);
+       if (out_fd < 0) {
+               ret = error("Could not lock config file!");
+               goto out;
+       }
+
+       if (!(config_file = fopen(config_filename, "rb"))) {
+               ret = error("Could not open config file!");
+               goto out;
+       }
+
+       while (fgets(buf, sizeof(buf), config_file)) {
+               int i;
+               for (i = 0; buf[i] && isspace(buf[i]); i++)
+                       ; /* do nothing */
+               if (buf[i] == '[') {
+                       /* it's a section */
+                       int j = 0, dot = 0;
+                       for (i++; buf[i] && buf[i] != ']'; i++) {
+                               if (!dot && isspace(buf[i])) {
+                                       dot = 1;
+                                       if (old_name[j++] != '.')
+                                               break;
+                                       for (i++; isspace(buf[i]); i++)
+                                               ; /* do nothing */
+                                       if (buf[i] != '"')
+                                               break;
+                                       continue;
+                               }
+                               if (buf[i] == '\\' && dot)
+                                       i++;
+                               else if (buf[i] == '"' && dot) {
+                                       for (i++; isspace(buf[i]); i++)
+                                               ; /* do_nothing */
+                                       break;
+                               }
+                               if (buf[i] != old_name[j++])
+                                       break;
+                       }
+                       if (buf[i] == ']') {
+                               /* old_name matches */
+                               ret++;
+                               store.baselen = strlen(new_name);
+                               store_write_section(out_fd, new_name);
+                               continue;
+                       }
+               }
+               write(out_fd, buf, strlen(buf));
+       }
+       fclose(config_file);
+       if (close(out_fd) || commit_lock_file(lock) < 0)
+               ret = error("Cannot commit config file!");
+ out:
+       free(config_filename);
+       return ret;
+}
 
index 34e34789bd295d0e06e548c797acc73889928053..e153d5382364def42fa062a39148a696e2e49785 100644 (file)
@@ -316,10 +316,6 @@ GIT_PARSE_WITH(iconv))
 
 ## --enable-FEATURE[=ARG] and --disable-FEATURE
 #
-# Define COLLISION_CHECK below if you believe that SHA1's
-# 1461501637330902918203684832716283019655932542976 hashes do not give you
-# sufficient guarantee that no collisions between objects will ever happen.
-#
 # Define USE_NSEC below if you want git to care about sub-second file mtimes
 # and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
 # it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely
index f7edba82c4d2fcc642ccae785aa7a315b1f819d6..66daa11a5737efd6ee2dbd6ff2ad0e1475fcba20 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -3,12 +3,6 @@
 #include "pkt-line.h"
 #include "quote.h"
 #include "refs.h"
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <signal.h>
 
 static char *server_capabilities;
 
index a9de09fa2fec161d6a0170553f2b507bca483cef..d911efbb4b2e5a15d7550e5f1513b81915d7a6a9 100644 (file)
@@ -1,7 +1,7 @@
 syn region gitLine start=/^#/ end=/$/
-syn region gitCommit start=/^# Updated but not checked in:$/ end=/^#$/ contains=gitHead,gitCommitFile
+syn region gitCommit start=/^# Added but not yet committed:$/ end=/^#$/ contains=gitHead,gitCommitFile
 syn region gitHead contained start=/^#   (.*)/ end=/^#$/
-syn region gitChanged start=/^# Changed but not updated:/ end=/^#$/ contains=gitHead,gitChangedFile
+syn region gitChanged start=/^# Changed but not added:/ end=/^#$/ contains=gitHead,gitChangedFile
 syn region gitUntracked start=/^# Untracked files:/ end=/^#$/ contains=gitHead,gitUntrackedFile
 
 syn match gitCommitFile contained /^#\t.*/hs=s+2
index 881258311a47f9faa437ec02e99b4a0df1439d53..a63013298566fd3dc21275a90ca976227de8c7f0 100644 (file)
@@ -1,7 +1,3 @@
-#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
-#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
-#define _GNU_SOURCE
-#include <time.h>
 #include "cache.h"
 #include "blob.h"
 #include "commit.h"
index e66bb802da9faed6e01229fffbe56e3d7cca60c6..b129b83e4026490c1e6e77861cd6f03a5007d01e 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -1,20 +1,10 @@
-#include <signal.h>
-#include <sys/wait.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/poll.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <syslog.h>
-#include <pwd.h>
-#include <grp.h>
-#include <limits.h>
-#include "pkt-line.h"
 #include "cache.h"
+#include "pkt-line.h"
 #include "exec_cmd.h"
 #include "interpolate.h"
 
+#include <syslog.h>
+
 #ifndef HOST_NAME_MAX
 #define HOST_NAME_MAX 256
 #endif
diff --git a/date.c b/date.c
index 18259227321f47988386c2bd70888b3c967d8ab6..7acb8cbd91bb1491931326ade1905d9c6f7bfdf5 100644 (file)
--- a/date.c
+++ b/date.c
@@ -4,9 +4,6 @@
  * Copyright (C) Linus Torvalds, 2005
  */
 
-#include <time.h>
-#include <sys/time.h>
-
 #include "cache.h"
 
 static time_t my_mktime(struct tm *tm)
index fa16d06c8d1e85a458428c673cb2f589857f5424..9f998d0a73e0127d3a68a7caecb3727569149871 100644 (file)
  *  licensing gets turned into GPLv2 within this project.
  */
 
-#include <stdlib.h>
-#include <string.h>
-#include "delta.h"
-
 #include "git-compat-util.h"
+#include "delta.h"
 
 /* maximum hash entry list for the same hash bucket */
 #define HASH_LIMIT 64
diff --git a/diff.c b/diff.c
index 99744354a77418ab462b6b797c6ab334cc364960..91f956b23b0d641e4e330e1e22c0b8bc8cc0fed0 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1,9 +1,6 @@
 /*
  * Copyright (C) 2005 Junio C Hamano
  */
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <signal.h>
 #include "cache.h"
 #include "quote.h"
 #include "diff.h"
@@ -1223,7 +1220,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
         * objects however would tend to be slower as they need
         * to be individually opened and inflated.
         */
-       if (FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))
+       if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))
                return 0;
 
        len = strlen(name);
index aef6da60447b98a05d91513b4aa74e505b0a0d84..7ad09461858aa6832b828df411fd1b736f035465 100644 (file)
@@ -4,7 +4,6 @@
 #include "cache.h"
 #include "diff.h"
 #include "diffcore.h"
-#include <fnmatch.h>
 
 static char **order;
 static int order_cnt;
index cfcce315babb0edb7ad7be7f2ab2437aaf41eb9d..de44adabf09dcb47090e7865d6cd77677115d2b6 100644 (file)
@@ -5,8 +5,6 @@
 #include "diff.h"
 #include "diffcore.h"
 
-#include <regex.h>
-
 static unsigned int contains(struct diff_filespec *one,
                             const char *needle, unsigned long len,
                             regex_t *regexp)
diff --git a/dir.c b/dir.c
index e6a61ee913d9f0f4f56402bdb451689cb80373ab..16401d8017c5d96dc17ac9d52ab77eabbc4e9270 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -5,9 +5,6 @@
  * Copyright (C) Linus Torvalds, 2005-2006
  *              Junio Hamano, 2005-2006
  */
-#include <dirent.h>
-#include <fnmatch.h>
-
 #include "cache.h"
 #include "dir.h"
 
diff --git a/entry.c b/entry.c
index b2ea0efa82e1a0511fe5aa798618c23827b59bab..88df7139477f94c236f93ca835c28ed4dd9543de 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -1,5 +1,3 @@
-#include <sys/types.h>
-#include <dirent.h>
 #include "cache.h"
 #include "blob.h"
 
index 5d6a1247b4a1955dffae2b52da064a6eb489d83b..3996bce33fe11b8f0bae120fabd40a74c66de342 100644 (file)
@@ -21,7 +21,7 @@ const char *git_exec_path(void)
        if (current_exec_path)
                return current_exec_path;
 
-       env = getenv("GIT_EXEC_PATH");
+       env = getenv(EXEC_PATH_ENVIRONMENT);
        if (env && *env) {
                return env;
        }
@@ -35,7 +35,7 @@ int execv_git_cmd(const char **argv)
        char git_command[PATH_MAX + 1];
        int i;
        const char *paths[] = { current_exec_path,
-                               getenv("GIT_EXEC_PATH"),
+                               getenv(EXEC_PATH_ENVIRONMENT),
                                builtin_exec_path };
 
        for (i = 0; i < ARRAY_SIZE(paths); ++i) {
index 743eab7efaa5b53a56d432bea268dda04350be7b..92322cf4da39434d44e4aa52fa0c3f735b22d752 100644 (file)
@@ -5,7 +5,6 @@
 #include "tag.h"
 #include "exec_cmd.h"
 #include "sideband.h"
-#include <sys/wait.h>
 
 static int keep_pack;
 static int quiet;
diff --git a/fetch.c b/fetch.c
index 663b4b2f42744a2d12ba1d8661b8b0d3645ef82b..f69be82f10d287d71f6184c4b9203bdab3ce81fc 100644 (file)
--- a/fetch.c
+++ b/fetch.c
@@ -1,6 +1,5 @@
-#include "fetch.h"
-
 #include "cache.h"
+#include "fetch.h"
 #include "commit.h"
 #include "tree.h"
 #include "tree-walk.h"
index 46b628cb94375e3f645f868efb04547ffc20e6e7..409aea02b4f8570dbaf0a8425eb29e5d45515367 100644 (file)
@@ -1,6 +1,3 @@
-#include <sys/types.h>
-#include <dirent.h>
-
 #include "cache.h"
 #include "commit.h"
 #include "tree.h"
index 1f5d07a057ed04dd9ffc7eb705d0c752d250bf72..490f3e48db02d01cb480047c011aa7b670c431bc 100755 (executable)
@@ -14,7 +14,7 @@ die() {
 }
 
 usage() {
-       die "Usage: $0 [--template=<template_directory>] [--no-separate-remote] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
+       die "Usage: $0 [--template=<template_directory>] [--reference <reference-repo>] [--bare] [-l [-s]] [-q] [-u <upload-pack>] [--origin <name>] [-n] <repo> [<dir>]"
 }
 
 get_repo_base() {
@@ -137,11 +137,9 @@ while
        *,--template=*)
          template="$1" ;;
        *,-q|*,--quiet) quiet=-q ;;
-       *,--use-separate-remote)
-               # default
-               use_separate_remote=t ;;
+       *,--use-separate-remote) ;;
        *,--no-separate-remote)
-               use_separate_remote= ;;
+               die "clones are always made with separate-remote layout" ;;
        1,--reference) usage ;;
        *,--reference)
                shift; reference="$1" ;;
@@ -327,12 +325,8 @@ cd "$D" || exit
 
 if test -z "$bare" && test -f "$GIT_DIR/REMOTE_HEAD"
 then
-       # Figure out which remote branch HEAD points at.
-       case "$use_separate_remote" in
-       '')     remote_top=refs/heads ;;
-       *)      remote_top="refs/remotes/$origin" ;;
-       esac
-
+       # a non-bare repository is always in separate-remote layout
+       remote_top="refs/remotes/$origin"
        head_sha1=`cat "$GIT_DIR/REMOTE_HEAD"`
        case "$head_sha1" in
        'ref: refs/'*)
@@ -366,41 +360,26 @@ then
                )
        )
 
-       # Write out remotes/$origin file, and update our "$head_points_at".
+       # Write out remote.$origin config, and update our "$head_points_at".
        case "$head_points_at" in
        ?*)
-               mkdir -p "$GIT_DIR/remotes" &&
+               # Local default branch
                git-symbolic-ref HEAD "refs/heads/$head_points_at" &&
-               case "$use_separate_remote" in
-               t)      origin_track="$remote_top/$head_points_at"
-                       git-update-ref HEAD "$head_sha1" ;;
-               *)      origin_track="$remote_top/$origin"
-                       git-update-ref "refs/heads/$origin" "$head_sha1" ;;
-               esac &&
+
+               # Tracking branch for the primary branch at the remote.
+               origin_track="$remote_top/$head_points_at" &&
+               git-update-ref HEAD "$head_sha1" &&
+
+               # Upstream URL
                git-repo-config remote."$origin".url "$repo" &&
+
+               # Set up the mappings to track the remote branches.
                git-repo-config remote."$origin".fetch \
-                       "refs/heads/$head_points_at:$origin_track" &&
-               (cd "$GIT_DIR/$remote_top" && find . -type f -print) |
-               while read dotslref
-               do
-                       name=`expr "$dotslref" : './\(.*\)'`
-                       if test "z$head_points_at" = "z$name"
-                       then
-                               continue
-                       fi
-                       if test "$use_separate_remote" = '' &&
-                          test "z$origin" = "z$name"
-                       then
-                               continue
-                       fi
-                       git-repo-config remote."$origin".fetch "refs/heads/${name}:$remote_top/${name}" '^$'
-               done &&
-               case "$use_separate_remote" in
-               t)
-                       rm -f "refs/remotes/$origin/HEAD"
-                       git-symbolic-ref "refs/remotes/$origin/HEAD" \
-                               "refs/remotes/$origin/$head_points_at"
-               esac &&
+                       "refs/heads/*:$remote_top/*" '^$' &&
+               rm -f "refs/remotes/$origin/HEAD"
+               git-symbolic-ref "refs/remotes/$origin/HEAD" \
+                       "refs/remotes/$origin/$head_points_at" &&
+
                git-repo-config branch."$head_points_at".remote "$origin" &&
                git-repo-config branch."$head_points_at".merge "refs/heads/$head_points_at"
        esac
index 0272d043d0b82dc6ad0ff4836fe8db8ed1e1d960..bc296b3a45708296c3f14f5af53624801045e554 100644 (file)
 
 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
 
+#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
+#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
+#define _GNU_SOURCE
+#define _BSD_SOURCE
+
 #include <unistd.h>
 #include <stdio.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <limits.h>
 #include <sys/param.h>
-#include <netinet/in.h>
 #include <sys/types.h>
 #include <dirent.h>
+#include <sys/time.h>
+#include <time.h>
+#include <signal.h>
+#include <sys/wait.h>
+#include <fnmatch.h>
+#include <sys/poll.h>
+#include <sys/socket.h>
+#include <assert.h>
+#include <regex.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <pwd.h>
+#include <grp.h>
+
+#ifndef NO_ICONV
+#include <iconv.h>
+#endif
 
 /* On most systems <limits.h> would have given us this, but
  * not on some systems (e.g. GNU/Hurd).
index 2a8447e2534e93b4cec4e86c2dcbadfede99208a..df395126b86bbed4d8f785e7eccbdb091c3f888b 100755 (executable)
@@ -946,7 +946,7 @@ sub req_update
 
             $log->debug("Temporary directory for merge is $dir");
 
-            my $return = system("git merge-file", $file_local, $file_old, $file_new);
+            my $return = system("git", "merge-file", $file_local, $file_old, $file_new);
             $return >>= 8;
 
             if ( $return == 0 )
index fb35815a5fbf1074f6a4a2fb08c6c9656c6a1654..ffbd44f0e1ab841e6f6a38295860220b01bb26ea 100755 (executable)
@@ -96,7 +96,7 @@ fi
 
 # Global that is reused later
 ls_remote_result=$(git ls-remote $upload_pack "$remote") ||
-       die "Cannot find the reflist at $remote"
+       die "Cannot get the repository state from $remote"
 
 append_fetch_head () {
     head_="$1"
@@ -242,7 +242,7 @@ esac
 reflist=$(get_remote_refs_for_fetch "$@")
 if test "$tags"
 then
-       taglist=`IFS="  " &&
+       taglist=`IFS='  ' &&
                  echo "$ls_remote_result" |
                  while read sha1 name
                  do
@@ -438,17 +438,11 @@ case "$no_tags$tags" in
        *:refs/*)
                # effective only when we are following remote branch
                # using local tracking branch.
-               taglist=$(IFS=" " &&
+               taglist=$(IFS=' ' &&
                echo "$ls_remote_result" |
-               sed -n  -e 's|^\('"$_x40"'\)    \(refs/tags/.*\)^{}$|\1 \2|p' \
-                       -e 's|^\('"$_x40"'\)    \(refs/tags/.*\)$|\1 \2|p' |
+               git-show-ref --exclude-existing=refs/tags/ |
                while read sha1 name
                do
-                       git-show-ref --verify --quiet -- "$name" && continue
-                       git-check-ref-format "$name" || {
-                               echo >&2 "warning: tag ${name} ignored"
-                               continue
-                       }
                        git-cat-file -t "$sha1" >/dev/null 2>&1 || continue
                        echo >&2 "Auto-following $name"
                        echo ".${name}:${name}"
index 0f88953f299c1fd1243c3d5d6ae1e71d56e842a8..03b624ef33dd3690a3cf24b4eaab830e5875789b 100755 (executable)
@@ -94,7 +94,7 @@ while read sha1 path
 do
        case "$sha1" in
        failed)
-               die "Failed to find remote refs"
+               exit 1 ;;
        esac
        case "$path" in
        refs/heads/*)
index 6ae534bf89a7a1fd0bfeee4248c37b4ea71290b9..ea7511e8a0f18a3402146ce8acc1c051fc92475f 100755 (executable)
@@ -111,16 +111,14 @@ expand_refs_wildcard () {
                local_force=
                test "z$lref" = "z$ref" || local_force='+'
                echo "$ls_remote_result" |
+               sed -e '/\^{}$/d' |
                (
                        IFS='   '
                        while read sha1 name
                        do
+                               # ignore the ones that do not start with $from
                                mapped=${name#"$from"}
-                               if test "z$name" != "z${name%'^{}'}" ||
-                                       test "z$name" = "z$mapped"
-                               then
-                                       continue
-                               fi
+                               test "z$name" = "z$mapped" && continue
                                echo "${local_force}${name}:${to}${mapped}"
                        done
                )
@@ -134,7 +132,6 @@ canon_refs_list_for_fetch () {
        # or the first one otherwise; add prefix . to the rest
        # to prevent the secondary branches to be merged by default.
        merge_branches=
-       found_mergeref=
        curr_branch=
        if test "$1" = "-d"
        then
@@ -144,7 +141,8 @@ canon_refs_list_for_fetch () {
                        curr_branch=$(git-symbolic-ref HEAD | \
                            sed -e 's|^refs/heads/||')
                        merge_branches=$(git-repo-config \
-                           --get-all "branch.${curr_branch}.merge")
+                           --get-all "branch.${curr_branch}.merge") ||
+                       merge_branches=.this.would.never.match.any.ref.
                fi
                set x $(expand_refs_wildcard "$@")
                shift
@@ -173,10 +171,6 @@ canon_refs_list_for_fetch () {
                            dot_prefix= && break
                        done
                fi
-               if test -z $dot_prefix
-               then
-                       found_mergeref=true
-               fi
                case "$remote" in
                '') remote=HEAD ;;
                refs/heads/* | refs/tags/* | refs/remotes/*) ;;
@@ -197,11 +191,6 @@ canon_refs_list_for_fetch () {
                fi
                echo "${dot_prefix}${force}${remote}:${local}"
        done
-       if test -z "$found_mergeref" -a "$curr_branch"
-       then
-               echo >&2 "Warning: No merge candidate found because value of config option
-         \"branch.${curr_branch}.merge\" does not match any remote branch fetched."
-       fi
 }
 
 # Returns list of src: (no store), or src:dst (store)
index e23beb685d15447ac114c58d1795ed15bef88c9d..1703091bbb988e22f39b2c8d4c70ec7340a2f109 100755 (executable)
@@ -76,6 +76,10 @@ merge_head=$(sed -e '/       not-for-merge   /d' \
 
 case "$merge_head" in
 '')
+       curr_branch=$(git-symbolic-ref HEAD | \
+               sed -e 's|^refs/heads/||')
+       echo >&2 "Warning: No merge candidate found because value of config option
+         \"branch.${curr_branch}.merge\" does not match any remote branch fetched."
        echo >&2 "No changes."
        exit 0
        ;;
index fdd68548961247b38e637f61e280ab4084650475..4f692091e73bf633cf986ba2c9bed38bc2c78538 100755 (executable)
@@ -154,7 +154,7 @@ sub find_conflict {
 sub merge {
        my ($name, $path) = @_;
        record_preimage($path, "$rr_dir/$name/thisimage");
-       unless (system('git merge-file', map { "$rr_dir/$name/${_}image" }
+       unless (system('git', 'merge-file', map { "$rr_dir/$name/${_}image" }
                       qw(this pre post))) {
                my $in;
                open $in, "<$rr_dir/$name/thisimage" or
diff --git a/git.c b/git.c
index 016ee8adb730ea7c390dcb84dcbbafda7936f2d5..73cf4d4e019c2c0169e6181b2c557cdeb3f962e7 100644 (file)
--- a/git.c
+++ b/git.c
@@ -1,20 +1,8 @@
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <stdarg.h>
-#include "git-compat-util.h"
+#include "builtin.h"
 #include "exec_cmd.h"
 #include "cache.h"
 #include "quote.h"
 
-#include "builtin.h"
-
 const char git_usage_string[] =
        "git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]";
 
index 5ea3fda540f00e4b7ee2c11c380eac86168eca17..ebbc397ee8dce807bd9700aa72d33c80b13f02bf 100755 (executable)
@@ -434,6 +434,7 @@ my %actions = (
        "tags" => \&git_tags,
        "tree" => \&git_tree,
        "snapshot" => \&git_snapshot,
+       "object" => \&git_object,
        # those below don't need $project
        "opml" => \&git_opml,
        "project_list" => \&git_project_list,
@@ -827,14 +828,12 @@ sub format_log_line_html {
        my $line = shift;
 
        $line = esc_html($line, -nbsp=>1);
-       if ($line =~ m/([0-9a-fA-F]{40})/) {
+       if ($line =~ m/([0-9a-fA-F]{8,40})/) {
                my $hash_text = $1;
-               if (git_get_type($hash_text) eq "commit") {
-                       my $link =
-                               $cgi->a({-href => href(action=>"commit", hash=>$hash_text),
-                                       -class => "text"}, $hash_text);
-                       $line =~ s/$hash_text/$link/;
-               }
+               my $link =
+                       $cgi->a({-href => href(action=>"object", hash=>$hash_text),
+                               -class => "text"}, $hash_text);
+               $line =~ s/$hash_text/$link/;
        }
        return $line;
 }
@@ -856,7 +855,8 @@ sub format_ref_marker {
                                $name = $ref;
                        }
 
-                       $markers .= " <span class=\"$type\">" . esc_html($name) . "</span>";
+                       $markers .= " <span class=\"$type\" title=\"$ref\">" .
+                                   esc_html($name) . "</span>";
                }
        }
 
@@ -1989,12 +1989,73 @@ sub git_print_log ($;%) {
        }
 }
 
+# return link target (what link points to)
+sub git_get_link_target {
+       my $hash = shift;
+       my $link_target;
+
+       # read link
+       open my $fd, "-|", git_cmd(), "cat-file", "blob", $hash
+               or return;
+       {
+               local $/;
+               $link_target = <$fd>;
+       }
+       close $fd
+               or return;
+
+       return $link_target;
+}
+
+# given link target, and the directory (basedir) the link is in,
+# return target of link relative to top directory (top tree);
+# return undef if it is not possible (including absolute links).
+sub normalize_link_target {
+       my ($link_target, $basedir, $hash_base) = @_;
+
+       # we can normalize symlink target only if $hash_base is provided
+       return unless $hash_base;
+
+       # absolute symlinks (beginning with '/') cannot be normalized
+       return if (substr($link_target, 0, 1) eq '/');
+
+       # normalize link target to path from top (root) tree (dir)
+       my $path;
+       if ($basedir) {
+               $path = $basedir . '/' . $link_target;
+       } else {
+               # we are in top (root) tree (dir)
+               $path = $link_target;
+       }
+
+       # remove //, /./, and /../
+       my @path_parts;
+       foreach my $part (split('/', $path)) {
+               # discard '.' and ''
+               next if (!$part || $part eq '.');
+               # handle '..'
+               if ($part eq '..') {
+                       if (@path_parts) {
+                               pop @path_parts;
+                       } else {
+                               # link leads outside repository (outside top dir)
+                               return;
+                       }
+               } else {
+                       push @path_parts, $part;
+               }
+       }
+       $path = join('/', @path_parts);
+
+       return $path;
+}
+
 # print tree entry (row of git_tree), but without encompassing <tr> element
 sub git_print_tree_entry {
        my ($t, $basedir, $hash_base, $have_blame) = @_;
 
        my %base_key = ();
-       $base_key{hash_base} = $hash_base if defined $hash_base;
+       $base_key{'hash_base'} = $hash_base if defined $hash_base;
 
        # The format of a table row is: mode list link.  Where mode is
        # the mode of the entry, list is the name of the entry, an href,
@@ -2005,16 +2066,31 @@ sub git_print_tree_entry {
                print "<td class=\"list\">" .
                        $cgi->a({-href => href(action=>"blob", hash=>$t->{'hash'},
                                               file_name=>"$basedir$t->{'name'}", %base_key),
-                               -class => "list"}, esc_path($t->{'name'})) . "</td>\n";
+                               -class => "list"}, esc_path($t->{'name'}));
+               if (S_ISLNK(oct $t->{'mode'})) {
+                       my $link_target = git_get_link_target($t->{'hash'});
+                       if ($link_target) {
+                               my $norm_target = normalize_link_target($link_target, $basedir, $hash_base);
+                               if (defined $norm_target) {
+                                       print " -> " .
+                                             $cgi->a({-href => href(action=>"object", hash_base=>$hash_base,
+                                                                    file_name=>$norm_target),
+                                                      -title => $norm_target}, esc_path($link_target));
+                               } else {
+                                       print " -> " . esc_path($link_target);
+                               }
+                       }
+               }
+               print "</td>\n";
                print "<td class=\"link\">";
                print $cgi->a({-href => href(action=>"blob", hash=>$t->{'hash'},
-                                            file_name=>"$basedir$t->{'name'}", %base_key)},
-                             "blob");
+                                            file_name=>"$basedir$t->{'name'}", %base_key)},
+                             "blob");
                if ($have_blame) {
                        print " | " .
                              $cgi->a({-href => href(action=>"blame", hash=>$t->{'hash'},
-                                                          file_name=>"$basedir$t->{'name'}", %base_key)},
-                                           "blame");
+                                                    file_name=>"$basedir$t->{'name'}", %base_key)},
+                                     "blame");
                }
                if (defined $hash_base) {
                        print " | " .
@@ -2036,8 +2112,8 @@ sub git_print_tree_entry {
                print "</td>\n";
                print "<td class=\"link\">";
                print $cgi->a({-href => href(action=>"tree", hash=>$t->{'hash'},
-                                            file_name=>"$basedir$t->{'name'}", %base_key)},
-                             "tree");
+                                            file_name=>"$basedir$t->{'name'}", %base_key)},
+                             "tree");
                if (defined $hash_base) {
                        print " | " .
                              $cgi->a({-href => href(action=>"history", hash_base=>$hash_base,
@@ -2839,8 +2915,10 @@ sub git_summary {
        my $owner = git_get_project_owner($project);
 
        my $refs = git_get_references();
-       my @taglist  = git_get_tags_list(15);
-       my @headlist = git_get_heads_list(15);
+       # These get_*_list functions return one more to allow us to see if
+       # there are more ...
+       my @taglist  = git_get_tags_list(16);
+       my @headlist = git_get_heads_list(16);
        my @forklist;
        my ($check_forks) = gitweb_check_feature('forks');
 
@@ -2876,6 +2954,8 @@ sub git_summary {
                }
        }
 
+       # we need to request one more than 16 (0..15) to check if
+       # those 16 are all
        open my $fd, "-|", git_cmd(), "rev-list", "--max-count=17",
                git_get_head_hash($project), "--"
                or die_error(undef, "Open git-rev-list failed");
@@ -2883,17 +2963,20 @@ sub git_summary {
        close $fd;
        git_print_header_div('shortlog');
        git_shortlog_body(\@revlist, 0, 15, $refs,
+                         $#revlist <=  15 ? undef :
                          $cgi->a({-href => href(action=>"shortlog")}, "..."));
 
        if (@taglist) {
                git_print_header_div('tags');
                git_tags_body(\@taglist, 0, 15,
+                             $#taglist <=  15 ? undef :
                              $cgi->a({-href => href(action=>"tags")}, "..."));
        }
 
        if (@headlist) {
                git_print_header_div('heads');
                git_heads_body(\@headlist, $head, 0, 15,
+                              $#headlist <= 15 ? undef :
                               $cgi->a({-href => href(action=>"heads")}, "..."));
        }
 
@@ -3414,8 +3497,7 @@ sub git_snapshot {
        my $filename = basename($project) . "-$hash.tar.$suffix";
 
        print $cgi->header(
-               -type => 'application/x-tar',
-               -content_encoding => $ctype,
+               -type => "application/$ctype",
                -content_disposition => 'inline; filename="' . "$filename" . '"',
                -status => '200 OK');
 
@@ -3497,15 +3579,46 @@ sub git_commit {
        my %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});
        my %cd = parse_date($co{'committer_epoch'}, $co{'committer_tz'});
 
-       my $parent = $co{'parent'};
+       my $parent  = $co{'parent'};
+       my $parents = $co{'parents'}; # listref
+
+       # we need to prepare $formats_nav before any parameter munging
+       my $formats_nav;
+       if (!defined $parent) {
+               # --root commitdiff
+               $formats_nav .= '(initial)';
+       } elsif (@$parents == 1) {
+               # single parent commit
+               $formats_nav .=
+                       '(parent: ' .
+                       $cgi->a({-href => href(action=>"commit",
+                                              hash=>$parent)},
+                               esc_html(substr($parent, 0, 7))) .
+                       ')';
+       } else {
+               # merge commit
+               $formats_nav .=
+                       '(merge: ' .
+                       join(' ', map {
+                               $cgi->a({-href => href(action=>"commitdiff",
+                                                      hash=>$_)},
+                                       esc_html(substr($_, 0, 7)));
+                       } @$parents ) .
+                       ')';
+       }
+
        if (!defined $parent) {
                $parent = "--root";
        }
-       open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id",
-               @diff_opts, $parent, $hash, "--"
-               or die_error(undef, "Open git-diff-tree failed");
-       my @difftree = map { chomp; $_ } <$fd>;
-       close $fd or die_error(undef, "Reading git-diff-tree failed");
+       my @difftree;
+       if (@$parents <= 1) {
+               # difftree output is not printed for merges
+               open my $fd, "-|", git_cmd(), "diff-tree", '-r', "--no-commit-id",
+                       @diff_opts, $parent, $hash, "--"
+                               or die_error(undef, "Open git-diff-tree failed");
+               @difftree = map { chomp; $_ } <$fd>;
+               close $fd or die_error(undef, "Reading git-diff-tree failed");
+       }
 
        # non-textual hash id's can be cached
        my $expires;
@@ -3517,16 +3630,10 @@ sub git_commit {
 
        my $have_snapshot = gitweb_have_snapshot();
 
-       my @views_nav = ();
-       if (defined $file_name && defined $co{'parent'}) {
-               push @views_nav,
-                       $cgi->a({-href => href(action=>"blame", hash_parent=>$parent, file_name=>$file_name)},
-                               "blame");
-       }
        git_header_html(undef, $expires);
        git_print_page_nav('commit', '',
                           $hash, $co{'tree'}, $hash,
-                          join (' | ', @views_nav));
+                          $formats_nav);
 
        if (defined $co{'parent'}) {
                git_print_header_div('commitdiff', esc_html($co{'title'}) . $ref, $hash);
@@ -3567,7 +3674,7 @@ sub git_commit {
        }
        print "</td>" .
              "</tr>\n";
-       my $parents = $co{'parents'};
+
        foreach my $par (@$parents) {
                print "<tr>" .
                      "<td>parent</td>" .
@@ -3589,11 +3696,61 @@ sub git_commit {
        git_print_log($co{'comment'});
        print "</div>\n";
 
-       git_difftree_body(\@difftree, $hash, $parent);
+       if (@$parents <= 1) {
+               # do not output difftree/whatchanged for merges
+               git_difftree_body(\@difftree, $hash, $parent);
+       }
 
        git_footer_html();
 }
 
+sub git_object {
+       # object is defined by:
+       # - hash or hash_base alone
+       # - hash_base and file_name
+       my $type;
+
+       # - hash or hash_base alone
+       if ($hash || ($hash_base && !defined $file_name)) {
+               my $object_id = $hash || $hash_base;
+
+               my $git_command = git_cmd_str();
+               open my $fd, "-|", "$git_command cat-file -t $object_id 2>/dev/null"
+                       or die_error('404 Not Found', "Object does not exist");
+               $type = <$fd>;
+               chomp $type;
+               close $fd
+                       or die_error('404 Not Found', "Object does not exist");
+
+       # - hash_base and file_name
+       } elsif ($hash_base && defined $file_name) {
+               $file_name =~ s,/+$,,;
+
+               system(git_cmd(), "cat-file", '-e', $hash_base) == 0
+                       or die_error('404 Not Found', "Base object does not exist");
+
+               # here errors should not hapen
+               open my $fd, "-|", git_cmd(), "ls-tree", $hash_base, "--", $file_name
+                       or die_error(undef, "Open git-ls-tree failed");
+               my $line = <$fd>;
+               close $fd;
+
+               #'100644 blob 0fa3f3a66fb6a137f6ec2c19351ed4d807070ffa  panic.c'
+               unless ($line && $line =~ m/^([0-9]+) (.+) ([0-9a-fA-F]{40})\t/) {
+                       die_error('404 Not Found', "File or directory for given base does not exist");
+               }
+               $type = $2;
+               $hash = $3;
+       } else {
+               die_error('404 Not Found', "Not enough information to find object");
+       }
+
+       print $cgi->redirect(-uri => href(action=>$type, -full=>1,
+                                         hash=>$hash, hash_base=>$hash_base,
+                                         file_name=>$file_name),
+                            -status => '302 Found');
+}
+
 sub git_blobdiff {
        my $format = shift || 'html';
 
diff --git a/grep.c b/grep.c
index 0fc078ec0ac42e39125c8e5a8f05a3b6ecae4fa3..fcc676230282e4c5bda4f9f97c5ae65c1a6beb30 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -1,5 +1,4 @@
 #include "cache.h"
-#include <regex.h>
 #include "grep.h"
 
 void append_grep_pattern(struct grep_opt *opt, const char *pat,
diff --git a/help.c b/help.c
index 0824c25226ad7b106e56d1b7c23fad40eed92749..341b9e370eec4fa90014249a63afac17b083b275 100644 (file)
--- a/help.c
+++ b/help.c
@@ -3,12 +3,11 @@
  *
  * Builtin help-related commands (help, usage, version)
  */
-#include <sys/ioctl.h>
 #include "cache.h"
 #include "builtin.h"
 #include "exec_cmd.h"
 #include "common-cmds.h"
-
+#include <sys/ioctl.h>
 
 /* most GUI terminals set COLUMNS (although some don't export it) */
 static int term_columns(void)
diff --git a/ident.c b/ident.c
index d7faba6a70139020d9ee0a2f801ae2e6b567d4f4..6ad8fedd60ba1461d77dc2b1d66e52cf56158c6f 100644 (file)
--- a/ident.c
+++ b/ident.c
@@ -7,9 +7,6 @@
  */
 #include "cache.h"
 
-#include <pwd.h>
-#include <netdb.h>
-
 static char git_default_date[50];
 
 static void copy_gecos(struct passwd *w, char *name, int sz)
index a6a65680ee6daf062180d2580e83616cfff4cda4..894cbbdf53ccf4728276b46b9491f409f3b9e03b 100644 (file)
 
 #include "cache.h"
 
-#include <assert.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
-#include <netdb.h>
-
 typedef struct store_conf {
        char *name;
        const char *path; /* should this be here? its interpretation is driver-specific */
index 6d6c92bf14803923f4c98678ae682aef4d41d3ab..5f6d128a836f8ed9447f81280ae679e19c9939ff 100644 (file)
@@ -6,8 +6,6 @@
 #include "commit.h"
 #include "tag.h"
 #include "tree.h"
-#include <sys/time.h>
-#include <signal.h>
 
 static const char index_pack_usage[] =
 "git-index-pack [-v] [-o <index-file>] [{ ---keep | --keep=<msg> }] { <pack-file> | --stdin [--fix-thin] [<pack-file>] }";
@@ -87,7 +85,7 @@ static unsigned display_progress(unsigned n, unsigned total, unsigned last_pc)
 static unsigned char input_buffer[4096];
 static unsigned long input_offset, input_len, consumed_bytes;
 static SHA_CTX input_ctx;
-static int input_fd, output_fd, mmap_fd;
+static int input_fd, output_fd, pack_fd;
 
 /* Discard current buffer used content. */
 static void flush(void)
@@ -148,14 +146,14 @@ static const char *open_pack_file(const char *pack_name)
                        output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);
                if (output_fd < 0)
                        die("unable to create %s: %s\n", pack_name, strerror(errno));
-               mmap_fd = output_fd;
+               pack_fd = output_fd;
        } else {
                input_fd = open(pack_name, O_RDONLY);
                if (input_fd < 0)
                        die("cannot open packfile '%s': %s",
                            pack_name, strerror(errno));
                output_fd = -1;
-               mmap_fd = input_fd;
+               pack_fd = input_fd;
        }
        SHA1_Init(&input_ctx);
        return pack_name;
@@ -268,7 +266,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
        case OBJ_TAG:
                break;
        default:
-               bad_object(obj->offset, "bad object type %d", obj->type);
+               bad_object(obj->offset, "unknown object type %d", obj->type);
        }
        obj->hdr_size = consumed_bytes - obj->offset;
 
@@ -279,27 +277,25 @@ static void *get_data_from_pack(struct object_entry *obj)
 {
        unsigned long from = obj[0].offset + obj[0].hdr_size;
        unsigned long len = obj[1].offset - from;
-       unsigned pg_offset = from % getpagesize();
-       unsigned char *map, *data;
+       unsigned char *src, *data;
        z_stream stream;
        int st;
 
-       map = mmap(NULL, len + pg_offset, PROT_READ, MAP_PRIVATE,
-                  mmap_fd, from - pg_offset);
-       if (map == MAP_FAILED)
-               die("cannot mmap pack file: %s", strerror(errno));
+       src = xmalloc(len);
+       if (pread(pack_fd, src, len, from) != len)
+               die("cannot pread pack file: %s", strerror(errno));
        data = xmalloc(obj->size);
        memset(&stream, 0, sizeof(stream));
        stream.next_out = data;
        stream.avail_out = obj->size;
-       stream.next_in = map + pg_offset;
+       stream.next_in = src;
        stream.avail_in = len;
        inflateInit(&stream);
        while ((st = inflate(&stream, Z_FINISH)) == Z_OK);
        inflateEnd(&stream);
        if (st != Z_STREAM_END || stream.total_out != obj->size)
                die("serious inflate inconsistency");
-       munmap(map, len + pg_offset);
+       free(src);
        return data;
 }
 
index 5d9d1889f088c64131cd3c116e6a16876ce95db8..f992ef77533737fe2ec52dc3b662cb6cacca0ea2 100644 (file)
@@ -2,8 +2,6 @@
  * Copyright 2006 Jon Loeliger
  */
 
-#include <string.h>
-
 #include "git-compat-util.h"
 #include "interpolate.h"
 
index 2a2fea3cb6bd1de059e7c0f8c2008c5fe8376b93..261baff049cd8b2e4d1b1a269992851eb00b2aa8 100644 (file)
@@ -1,7 +1,6 @@
 /*
  * Copyright (c) 2005, Junio C Hamano
  */
-#include <signal.h>
 #include "cache.h"
 
 static struct lock_file *lock_file_list;
index 009caf804b43fdd644ff08991d55d0e417fd34d8..385f4ba386ada3e43f962d9051cf4b651320fcd3 100644 (file)
@@ -1,4 +1,3 @@
-#include <stdlib.h>
 #include "cache.h"
 #include "commit.h"
 
index 646d090c58e774bdf0f412da39f4b67fd7a696c6..a9983dd78ad5cd1e364f0e00c259bdb7e6f151f0 100644 (file)
@@ -1,7 +1,3 @@
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <signal.h>
-
 #include "cache.h"
 
 static const char *pgm;
index 6dd6e2e5af779f2b3ad5da050776c37646b45a84..ae7ae4cd2a9ce392945ad8ed27e4289c27ee24bd 100644 (file)
@@ -3,13 +3,6 @@
  * Fredrik Kuivinen.
  * The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006
  */
-#include <stdarg.h>
-#include <string.h>
-#include <assert.h>
-#include <sys/wait.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <time.h>
 #include "cache.h"
 #include "cache-tree.h"
 #include "commit.h"
@@ -1279,7 +1272,7 @@ int main(int argc, char *argv[])
        struct commit *result, *h1, *h2;
 
        git_config(git_default_config); /* core.filemode */
-       original_index_file = getenv("GIT_INDEX_FILE");
+       original_index_file = getenv(INDEX_ENVIRONMENT);
 
        if (!original_index_file)
                original_index_file = xstrdup(git_path("index"));
index e3a1d425ee2e333bce0f87b1e50fc112a8ec51a3..ed9db81fa82c812c9ffa07f5a40540dbb15da0d3 100644 (file)
@@ -9,8 +9,7 @@
  * published by the Free Software Foundation.
  */
 
-#include <stdlib.h>
-#include <string.h>
+#include "git-compat-util.h"
 #include "delta.h"
 
 void *patch_delta(const void *src_buf, unsigned long src_size,
@@ -34,9 +33,7 @@ void *patch_delta(const void *src_buf, unsigned long src_size,
 
        /* now the result size */
        size = get_delta_hdr_size(&data, top);
-       dst_buf = malloc(size + 1);
-       if (!dst_buf)
-               return NULL;
+       dst_buf = xmalloc(size + 1);
        dst_buf[size] = 0;
 
        out = dst_buf;
@@ -55,13 +52,13 @@ void *patch_delta(const void *src_buf, unsigned long src_size,
                        if (cp_off + cp_size < cp_size ||
                            cp_off + cp_size > src_size ||
                            cp_size > size)
-                               goto bad;
+                               break;
                        memcpy(out, (char *) src_buf + cp_off, cp_size);
                        out += cp_size;
                        size -= cp_size;
                } else if (cmd) {
                        if (cmd > size)
-                               goto bad;
+                               break;
                        memcpy(out, data, cmd);
                        out += cmd;
                        data += cmd;
@@ -72,12 +69,14 @@ void *patch_delta(const void *src_buf, unsigned long src_size,
                         * extensions. In the mean time we must fail when
                         * encountering them (might be data corruption).
                         */
+                       error("unexpected delta opcode 0");
                        goto bad;
                }
        }
 
        /* sanity check */
        if (data != top || size != 0) {
+               error("delta replay has gone wild");
                bad:
                free(dst_buf);
                return NULL;
index f8800f8e66e39f035820c2aeb0843fb3ebf65fb3..caaa5cc57b05e1a27bb4fd8f49bb74e06b9936e3 100644 (file)
@@ -1,4 +1,3 @@
-#include <stdio.h>
 #include "cache.h"
 #include "path-list.h"
 
diff --git a/path.c b/path.c
index d2c076d7cbad3a16a002897d926cc13633be4f77..066f62195508033a5f72504e4805ea436424296e 100644 (file)
--- a/path.c
+++ b/path.c
@@ -11,7 +11,6 @@
  * which is what it's designed for.
  */
 #include "cache.h"
-#include <pwd.h>
 
 static char bad_path[] = "/bad-path/";
 
index c1e81f976f26726db2432f72f7356087a6e3a7d8..b4cb7e2756dcc52c17aebf4c0fc6adc7b415ef3c 100644 (file)
@@ -72,7 +72,7 @@ static void safe_read(int fd, void *buffer, unsigned size)
                if (ret < 0)
                        die("read error (%s)", strerror(errno));
                if (!ret)
-                       die("unexpected EOF");
+                       die("The remote end hung up unexpectedly");
                n += ret;
        }
 }
index 5e5510bc3dadff835324f46b0cd936ceba8f1c6e..59b682c03af53fbfe600d063fa832f874440493c 100644 (file)
@@ -6,7 +6,6 @@
 #include "exec_cmd.h"
 #include "commit.h"
 #include "object.h"
-#include <sys/wait.h>
 
 static const char receive_pack_usage[] = "git-receive-pack <git-dir>";
 
diff --git a/refs.c b/refs.c
index a02957c399ded94bb9a49c9dc3d8ab5d9411bbec..a101ff3bf88dafa56ac85fcd977c0ae6be1b495e 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -1,10 +1,8 @@
-#include "refs.h"
 #include "cache.h"
+#include "refs.h"
 #include "object.h"
 #include "tag.h"
 
-#include <errno.h>
-
 /* ISSYMREF=01 and ISPACKED=02 are public interfaces */
 #define REF_KNOWS_PEELED 04
 
@@ -867,6 +865,16 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
                goto rollback;
        }
 
+       if (!strncmp(oldref, "refs/heads/", 11) &&
+                       !strncmp(newref, "refs/heads/", 11)) {
+               char oldsection[1024], newsection[1024];
+
+               snprintf(oldsection, 1024, "branch.%s", oldref + 11);
+               snprintf(newsection, 1024, "branch.%s", newref + 11);
+               if (git_config_rename_section(oldsection, newsection) < 0)
+                       return 1;
+       }
+
        return 0;
 
  rollback:
index d84f46e5a663a61c05354abbffaf05feee991cb6..4dae5342eb6e14758c93fa4b2942d7c053111d04 100644 (file)
@@ -6,7 +6,6 @@
 #include "diff.h"
 #include "refs.h"
 #include "revision.h"
-#include <regex.h>
 #include "grep.h"
 
 static char *path_name(struct name_path *path, const char *name)
diff --git a/rsh.c b/rsh.c
index f34409e1bc5fcf3b6295021043339793b25a8913..5754a230e2c23ce3fea255fccd8726af76c13317 100644 (file)
--- a/rsh.c
+++ b/rsh.c
@@ -1,10 +1,6 @@
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
+#include "cache.h"
 #include "rsh.h"
 #include "quote.h"
-#include "cache.h"
 
 #define COMMAND_SIZE 4096
 
index 61908682b9b251ac49ae655522a3143476a888ea..492ad3e64ce5d2435c029ab032f1221347f37c19 100644 (file)
@@ -1,6 +1,5 @@
 #include "cache.h"
 #include "run-command.h"
-#include <sys/wait.h>
 #include "exec_cmd.h"
 
 int run_command_v_opt(int argc, const char **argv, int flags)
index 63f416bb5a900210d6b3ab15bb4ffe1e16244b9a..1c4df5b73e9dff900c69c0994eb21105614511b6 100644 (file)
@@ -1013,7 +1013,7 @@ void packed_object_info_detail(struct packed_git *p,
        for (;;) {
                switch (kind) {
                default:
-                       die("corrupted pack file %s containing object of kind %d",
+                       die("pack %s contains unknown object type %d",
                            p->pack_name, kind);
                case OBJ_COMMIT:
                case OBJ_TREE:
@@ -1063,7 +1063,7 @@ static int packed_object_info(struct packed_git *p, unsigned long offset,
                strcpy(type, type_names[kind]);
                break;
        default:
-               die("corrupted pack file %s containing object of kind %d",
+               die("pack %s contains unknown object type %d",
                    p->pack_name, kind);
        }
        if (sizep)
index 20b15eab57e1c4f7c4b306010d7d12bff2308141..0b52ae15cbd216bff5002c89e0c8af84ea68ed1a 100644 (file)
@@ -12,8 +12,6 @@
 #include "rsh.h"
 #include "refs.h"
 
-#include <string.h>
-
 static unsigned char local_version = 1;
 static unsigned char remote_version;
 
index 9d9d8bed915483abbc2ebb340e0881ae4e296bd4..7f14b0fb59bd7e14979b002f441ae84ff5b0e9a2 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -1,7 +1,5 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "strbuf.h"
 #include "cache.h"
+#include "strbuf.h"
 
 void strbuf_init(struct strbuf *sb) {
        sb->buf = NULL;
index 16cd6426100c0a58de854d3252a654c7ae28232a..e48a4ecdcf7129da1431928bdb942eae8c3e6515 100755 (executable)
@@ -343,5 +343,53 @@ EOF
 
 test_expect_success '--set in alternative GIT_CONFIG' 'cmp other-config expect'
 
+cat > .git/config << EOF
+# Hallo
+       #Bello
+[branch "eins"]
+       x = 1
+[branch.eins]
+       y = 1
+       [branch "1 234 blabl/a"]
+weird
+EOF
+
+test_expect_success "rename section" \
+       "git-repo-config --rename-section branch.eins branch.zwei"
+
+cat > expect << EOF
+# Hallo
+       #Bello
+[branch "zwei"]
+       x = 1
+[branch "zwei"]
+       y = 1
+       [branch "1 234 blabl/a"]
+weird
+EOF
+
+test_expect_success "rename succeeded" "diff -u expect .git/config"
+
+test_expect_failure "rename non-existing section" \
+       'git-repo-config --rename-section branch."world domination" branch.drei'
+
+test_expect_success "rename succeeded" "diff -u expect .git/config"
+
+test_expect_success "rename another section" \
+       'git-repo-config --rename-section branch."1 234 blabl/a" branch.drei'
+
+cat > expect << EOF
+# Hallo
+       #Bello
+[branch "zwei"]
+       x = 1
+[branch "zwei"]
+       y = 1
+[branch "drei"]
+weird
+EOF
+
+test_expect_success "rename succeeded" "diff -u expect .git/config"
+
 test_done
 
index 5782c30b03a7e7bb7d244d305e13e856eed40a89..a6ea0f6a196c5285c229021c96bb83f33a3aa748 100755 (executable)
@@ -94,6 +94,8 @@ test_expect_failure \
          git-branch r &&
          git-branch -m q r/q'
 
+git-repo-config branch.s/s.dummy Hello
+
 test_expect_success \
     'git branch -m s/s s should work when s/t is deleted' \
        'git-branch -l s/s &&
@@ -104,6 +106,10 @@ test_expect_success \
         git-branch -m s/s s &&
         test -f .git/logs/refs/heads/s'
 
+test_expect_success 'config information was renamed, too' \
+       "test $(git-repo-config branch.s.dummy) = Hello &&
+        ! git-repo-config branch.s/s/dummy"
+
 test_expect_failure \
     'git-branch -m u v should fail when the reflog for u is a symlink' \
     'git-branch -l u &&
index a11ab0ad41a006f9f20d8ec6172d34e6c7f92d41..90eeeba2a31949a84daeb34b1996eaa4818321e6 100755 (executable)
@@ -23,15 +23,14 @@ test_expect_success "clone and setup child repos" '
        git clone . two &&
        cd two &&
        git repo-config branch.master.remote one &&
-       {
-               echo "URL: ../one/.git/"
-               echo "Pull: refs/heads/master:refs/heads/one"
-       } >.git/remotes/one
+       git repo-config remote.one.url ../one/.git/ &&
+       git repo-config remote.one.fetch refs/heads/master:refs/heads/one &&
        cd .. &&
        git clone . three &&
        cd three &&
        git repo-config branch.master.remote two &&
        git repo-config branch.master.merge refs/heads/one &&
+       mkdir -p .git/remotes &&
        {
                echo "URL: ../two/.git/"
                echo "Pull: refs/heads/master:refs/heads/two"
index ac7be769b4d4f04908a64592a5c3ad8c43c27e60..f0f9cd6be01681c90d1914eaa8a40144e2280adf 100755 (executable)
@@ -208,8 +208,9 @@ test_done () {
 # t/ subdirectory and are run in trash subdirectory.
 PATH=$(pwd)/..:$PATH
 GIT_EXEC_PATH=$(pwd)/..
+GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
 HOME=$(pwd)/trash
-export PATH GIT_EXEC_PATH HOME
+export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR HOME
 
 GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
 export GITPERLLIB
diff --git a/templates/remotes-- b/templates/remotes--
deleted file mode 100644 (file)
index fae8870..0000000
+++ /dev/null
@@ -1 +0,0 @@
-: this is just to ensure the directory exists.
index 93e802759f1906665857c82c71f589b7d636b540..62e8f2387a1cab97ec1c71d1993d082274e17bf5 100644 (file)
@@ -1,6 +1,3 @@
-#include <stdio.h>
-#include <time.h>
-
 #include "cache.h"
 
 int main(int argc, char **argv)
index 1be8ee0c721ec35372fee4e686d9664b143b4345..795aa08377aaa9a229affaa054e243251436f755 100644 (file)
@@ -8,13 +8,7 @@
  * published by the Free Software Foundation.
  */
 
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
+#include "git-compat-util.h"
 #include "delta.h"
 
 static const char usage[] =
diff --git a/tree.c b/tree.c
index ea386e506659c65224cfe55bdc4f8d086171637a..b6f02fecc46ec4633dc1ee75f38bc90761a4fbe3 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -4,7 +4,6 @@
 #include "commit.h"
 #include "tag.h"
 #include "tree-walk.h"
-#include <stdlib.h>
 
 const char *tree_type = "tree";
 
index b8689ebc86bb69c21fd650572c55a4c3d246a183..2e2232cbb07e61de3be74302fba67142a58a857b 100644 (file)
@@ -1,5 +1,3 @@
-#include <signal.h>
-#include <sys/time.h>
 #include "cache.h"
 #include "dir.h"
 #include "tree.h"
index 4572fff07ca39a53a69453fdc8037e3aae1605a6..32b06b2e66099787d621c2557a8a9ee00aec4be6 100644 (file)
@@ -1,6 +1,3 @@
-#include <signal.h>
-#include <sys/wait.h>
-#include <sys/poll.h>
 #include "cache.h"
 #include "refs.h"
 #include "pkt-line.h"
diff --git a/var.c b/var.c
index a57a33b81ac6c9cb5ec0c833edc21bd66428d976..39977b949a1be61f1cf35512bd729862de842108 100644 (file)
--- a/var.c
+++ b/var.c
@@ -4,9 +4,6 @@
  * Copyright (C) Eric Biederman, 2005
  */
 #include "cache.h"
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
 
 static const char var_usage[] = "git-var [-l | <variable>]";
 
index cface6ca88666d5e1de116110cb52eea4d91a5f1..db427384ff454aa07e38c588537cbaa6b835dee6 100644 (file)
@@ -1,6 +1,6 @@
+#include "cache.h"
 #include "wt-status.h"
 #include "color.h"
-#include "cache.h"
 #include "object.h"
 #include "dir.h"
 #include "commit.h"