Merge branch 'sp/reflog' into next
authorJunio C Hamano <junkio@cox.net>
Tue, 23 May 2006 22:07:47 +0000 (15:07 -0700)
committerJunio C Hamano <junkio@cox.net>
Tue, 23 May 2006 22:07:47 +0000 (15:07 -0700)
* sp/reflog:
Enable ref log creation in git checkout -b.
Create/delete branch ref logs.
Include ref log detail in commit, reset, etc.
Change order of -m option to update-ref.
Correct force_write bug in refs.c
Change 'master@noon' syntax to 'master@{noon}'.
Log ref updates made by fetch.
Force writing ref if it doesn't exist.
Added logs/ directory to repository layout.
General ref log reading improvements.
Fix ref log parsing so it works properly.
Support 'master@2 hours ago' syntax
Log ref updates to logs/refs/<ref>
Convert update-ref to use ref_lock API.
Improve abstraction of ref lock/write.

1  2 
Documentation/git-branch.txt
Documentation/git-checkout.txt
cache.h
git-am.sh
git-commit.sh
http-fetch.c
index 0b37e2bfc85706ca6d41c1c9e4fedcdce53a7578,a7bec3c101bf050347c0ef87d8529d6258926b58..d43ef1dec4f27361af1a32983c53aeea15468fe9
@@@ -9,7 -9,7 +9,7 @@@ SYNOPSI
  --------
  [verse]
  'git-branch' [-r]
- 'git-branch' [-f] <branchname> [<start-point>]
+ 'git-branch' [-l] [-f] <branchname> [<start-point>]
  'git-branch' (-d | -D) <branchname>...
  
  DESCRIPTION
@@@ -23,7 -23,8 +23,8 @@@ If no <start-point> is given, the branc
  equal to that of the currently checked out branch.
  
  With a `-d` or `-D` option, `<branchname>` will be deleted.  You may
- specify more than one branch for deletion.
+ specify more than one branch for deletion.  If the branch currently
+ has a ref log then the ref log will also be deleted.
  
  
  OPTIONS
  -D::
        Delete a branch irrespective of its index status.
  
+ -l::
+       Create the branch's ref log.  This activates recording of
+       all changes to made the branch ref, enabling use of date
+       based sha1 expressions such as "<branchname>@{yesterday}".
  -f::
        Force the creation of a new branch even if it means deleting
        a branch that already exists with the same name.
@@@ -43,9 -49,6 +49,9 @@@
  
  <branchname>::
        The name of the branch to create or delete.
 +      The new branch name must pass all checks defined by
 +      gitlink:git-check-ref-format[1].  Some of these checks
 +      may restrict the characters allowed in a branch name.
  
  <start-point>::
        The new branch will be created with a HEAD equal to this.  It may
index d82efc00d403dc13ac1e85c53083ccc52a4c79f3,064394385486ca032c52e513c071ec08895a04c6..fbdbadc74fbe558285323353b7aa006f3cfd559b
@@@ -8,7 -8,7 +8,7 @@@ git-checkout - Checkout and switch to 
  SYNOPSIS
  --------
  [verse]
- 'git-checkout' [-f] [-b <new_branch>] [-m] [<branch>]
+ 'git-checkout' [-f] [-b <new_branch> [-l]] [-m] [<branch>]
  'git-checkout' [-m] [<branch>] <paths>...
  
  DESCRIPTION
@@@ -35,11 -35,13 +35,16 @@@ OPTION
        Force a re-read of everything.
  
  -b::
 -      Create a new branch and start it at <branch>.
 +      Create a new branch named <new_branch> and start it at
 +      <branch>.  The new branch name must pass all checks defined
 +      by gitlink:git-check-ref-format[1].  Some of these checks
 +      may restrict the characters allowed in a branch name.
  
+ -l::
+       Create the new branch's ref log.  This activates recording of
+       all changes to made the branch ref, enabling use of date
+       based sha1 expressions such as "<branchname>@{yesterday}".
  -m::
        If you have local modifications to one or more files that
        are different between the current branch and the branch to
diff --combined cache.h
index f11d5e7dcfa60c9f55a1babbe5768c7857b20e51,f01ca436e64270feb4bb1849376190fbc5693902..d530af97ccbcdbebcbb82fdcaeebadc66166f104
+++ b/cache.h
@@@ -114,7 -114,6 +114,7 @@@ static inline unsigned int create_ce_mo
  
  extern struct cache_entry **active_cache;
  extern unsigned int active_nr, active_alloc, active_cache_changed;
 +extern struct cache_tree *active_cache_tree;
  
  #define GIT_DIR_ENVIRONMENT "GIT_DIR"
  #define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
@@@ -143,7 -142,6 +143,7 @@@ extern void verify_non_filename(const c
  /* Initialize and use the cache information */
  extern int read_cache(void);
  extern int write_cache(int newfd, struct cache_entry **cache, int entries);
 +extern int verify_path(const char *path);
  extern int cache_name_pos(const char *name, int namelen);
  #define ADD_CACHE_OK_TO_ADD 1         /* Ok to add */
  #define ADD_CACHE_OK_TO_REPLACE 2     /* Ok to replace file/directory */
@@@ -156,17 -154,10 +156,17 @@@ extern int ce_match_stat(struct cache_e
  extern int ce_modified(struct cache_entry *ce, struct stat *st, int);
  extern int ce_path_match(const struct cache_entry *ce, const char **pathspec);
  extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, const char *type);
 +extern int read_pipe(int fd, char** return_buf, unsigned long* return_size);
  extern int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object);
  extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object);
  extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);
  
 +#define REFRESH_REALLY                0x0001  /* ignore_valid */
 +#define REFRESH_UNMERGED      0x0002  /* allow unmerged */
 +#define REFRESH_QUIET         0x0004  /* be quiet about it */
 +#define REFRESH_IGNORE_MISSING        0x0008  /* ignore non-existent */
 +extern int refresh_cache(unsigned int flags);
 +
  struct cache_file {
        struct cache_file *next;
        char lockfile[PATH_MAX];
@@@ -179,6 -170,7 +179,7 @@@ extern void rollback_index_file(struct 
  extern int trust_executable_bit;
  extern int assume_unchanged;
  extern int prefer_symlink_refs;
+ extern int log_all_ref_updates;
  extern int warn_ambiguous_refs;
  extern int diff_rename_limit_default;
  extern int shared_repository;
diff --combined git-am.sh
index 97ec2d0c7db521047e254e53120ffc83829868a9,25c95c24fde6894544f4b53439abd030008e757f..4232e27411036e339f8102e45b7cb699c808a798
+++ b/git-am.sh
@@@ -59,12 -59,46 +59,12 @@@ fall_back_3way () 
        GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
        git-write-tree >"$dotest/patch-merge-base+" &&
        # index has the base tree now.
 -      (
 -          cd "$dotest/patch-merge-tmp-dir" &&
 -          GIT_INDEX_FILE="../patch-merge-tmp-index" \
 -          GIT_OBJECT_DIRECTORY="$O_OBJECT" \
 -          git-apply $binary --index <../patch
 -        )
 +      GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
 +      git-apply $binary --cached <"$dotest/patch"
      then
        echo Using index info to reconstruct a base tree...
        mv "$dotest/patch-merge-base+" "$dotest/patch-merge-base"
        mv "$dotest/patch-merge-tmp-index" "$dotest/patch-merge-index"
 -    else
 -      # Otherwise, try nearby trees that can be used to apply the
 -      # patch.
 -      (
 -          N=10
 -
 -          # Hoping the patch is against our recent commits...
 -          git-rev-list --max-count=$N HEAD
 -
 -          # or hoping the patch is against known tags...
 -          git-ls-remote --tags .
 -      ) |
 -      while read base junk
 -      do
 -          # See if we have it as a tree...
 -          git-cat-file tree "$base" >/dev/null 2>&1 || continue
 -
 -          rm -fr "$dotest"/patch-merge-* &&
 -          mkdir "$dotest/patch-merge-tmp-dir" || break
 -          (
 -              cd "$dotest/patch-merge-tmp-dir" &&
 -              GIT_INDEX_FILE=../patch-merge-tmp-index &&
 -              GIT_OBJECT_DIRECTORY="$O_OBJECT" &&
 -              export GIT_INDEX_FILE GIT_OBJECT_DIRECTORY &&
 -              git-read-tree "$base" &&
 -              git-apply $binary --index &&
 -              mv ../patch-merge-tmp-index ../patch-merge-index &&
 -              echo "$base" >../patch-merge-base
 -          ) <"$dotest/patch"  2>/dev/null && break
 -      done
      fi
  
      test -f "$dotest/patch-merge-index" &&
@@@ -413,7 -447,7 +413,7 @@@ d
        parent=$(git-rev-parse --verify HEAD) &&
        commit=$(git-commit-tree $tree -p $parent <"$dotest/final-commit") &&
        echo Committed: $commit &&
-       git-update-ref HEAD $commit $parent ||
+       git-update-ref -m "am: $SUBJECT" HEAD $commit $parent ||
        stop_here $this
  
        if test -x "$GIT_DIR"/hooks/post-applypatch
diff --combined git-commit.sh
index 6785826fef91d35277107ae15a96619d2f5113c6,a4b0a907404f84581503d62011e5e82ecf50e715..0a01a0b96a0ae92e7cd7828ad622281bfcd72283
@@@ -3,7 -3,7 +3,7 @@@
  # Copyright (c) 2005 Linus Torvalds
  # Copyright (c) 2006 Junio C Hamano
  
 -USAGE='[-a] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit>) [--amend] [-e] [--author <author>] [[-i | -o] <path>...]'
 +USAGE='[-a] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit>] [-u] [--amend] [-e] [--author <author>] [[-i | -o] <path>...]'
  SUBDIRECTORY_OK=Yes
  . git-sh-setup
  
@@@ -134,17 -134,13 +134,17 @@@ run_status () 
        report "Changed but not updated" \
            "use git-update-index to mark for commit"
  
 +        option=""
 +        if test -z "$untracked_files"; then
 +            option="--directory --no-empty-directory"
 +        fi
        if test -f "$GIT_DIR/info/exclude"
        then
 -          git-ls-files -z --others --directory \
 +          git-ls-files -z --others $option \
                --exclude-from="$GIT_DIR/info/exclude" \
                --exclude-per-directory=.gitignore
        else
 -          git-ls-files -z --others --directory \
 +          git-ls-files -z --others $option \
                --exclude-per-directory=.gitignore
        fi |
        perl -e '$/ = "\0";
@@@ -207,7 -203,6 +207,7 @@@ verbose
  signoff=
  force_author=
  only_include_assumed=
 +untracked_files=
  while case "$#" in 0) break;; esac
  do
    case "$1" in
        verbose=t
        shift
        ;;
 +  -u|--u|--un|--unt|--untr|--untra|--untrac|--untrack|--untracke|--untracked|\
 +  --untracked-|--untracked-f|--untracked-fi|--untracked-fil|--untracked-file|\
 +  --untracked-files)
 +      untracked_files=t
 +      shift
 +      ;;
    --)
        shift
        break
@@@ -687,7 -676,8 +687,8 @@@ the
                rm -f "$TMP_INDEX"
        fi &&
        commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) &&
-       git-update-ref HEAD $commit $current &&
+       rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) &&
+       git-update-ref -m "commit: $rlogm" HEAD $commit $current &&
        rm -f -- "$GIT_DIR/MERGE_HEAD" &&
        if test -f "$NEXT_INDEX"
        then
diff --combined http-fetch.c
index 178f1ee311dd7db8ad6c2d10babde1a8c8fe7ebd,cc7bd1f3676d58f62bb0c1e5d029d9273aecf2c0..661c909152925ea3c9a375c13121200067e97cd2
@@@ -1223,6 -1223,7 +1223,7 @@@ int main(int argc, char **argv
        int rc = 0;
  
        setup_git_directory();
+       git_config(git_default_config);
  
        while (arg < argc && argv[arg][0] == '-') {
                if (argv[arg][1] == 't') {
        }
        commit_id = argv[arg];
        url = argv[arg + 1];
+       write_ref_log_details = url;
  
        http_init();
  
        if (pull(commit_id))
                rc = 1;
  
 -      curl_slist_free_all(no_pragma_header);
 -
        http_cleanup();
  
 +      curl_slist_free_all(no_pragma_header);
 +
        if (corrupt_object_found) {
                fprintf(stderr,
  "Some loose object were found to be corrupt, but they might be just\n"