1. 28 5月, 2008 1 次提交
  2. 02 2月, 2008 1 次提交
    • J
      Sane use of test_expect_failure · 41ac414e
      Junio C Hamano 提交于
      Originally, test_expect_failure was designed to be the opposite
      of test_expect_success, but this was a bad decision.  Most tests
      run a series of commands that leads to the single command that
      needs to be tested, like this:
      
          test_expect_{success,failure} 'test title' '
      	setup1 &&
              setup2 &&
              setup3 &&
              what is to be tested
          '
      
      And expecting a failure exit from the whole sequence misses the
      point of writing tests.  Your setup$N that are supposed to
      succeed may have failed without even reaching what you are
      trying to test.  The only valid use of test_expect_failure is to
      check a trivial single command that is expected to fail, which
      is a minority in tests of Porcelain-ish commands.
      
      This large-ish patch rewrites all uses of test_expect_failure to
      use test_expect_success and rewrites the condition of what is
      tested, like this:
      
          test_expect_success 'test title' '
      	setup1 &&
              setup2 &&
              setup3 &&
              ! this command should fail
          '
      
      test_expect_failure is redefined to serve as a reminder that
      that test *should* succeed but due to a known breakage in git it
      currently does not pass.  So if git-foo command should create a
      file 'bar' but you discovered a bug that it doesn't, you can
      write a test like this:
      
          test_expect_failure 'git-foo should create bar' '
              rm -f bar &&
              git foo &&
              test -f bar
          '
      
      This construct acts similar to test_expect_success, but instead
      of reporting "ok/FAIL" like test_expect_success does, the
      outcome is reported as "FIXED/still broken".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      41ac414e
  3. 17 1月, 2008 1 次提交
    • L
      Be more careful about updating refs · c3b0dec5
      Linus Torvalds 提交于
      This makes write_ref_sha1() more careful: it actually checks the SHA1 of
      the ref it is updating, and refuses to update a ref with an object that it
      cannot find.
      
      Perhaps more importantly, it also refuses to update a branch head with a
      non-commit object. I don't quite know *how* the stable series maintainers
      were able to corrupt their repository to have a HEAD that pointed to a tag
      rather than a commit object, but they did. Which results in a totally
      broken repository that cannot be cloned or committed on.
      
      So make it harder for people to shoot themselves in the foot like that.
      
      The test t1400-update-ref.sh is fixed at the same time, as it
      assumed that the commands involved in the particular test would
      not care about corrupted repositories whose refs point at
      nonexistant bogus objects.  That assumption does not hold true
      anymore.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c3b0dec5
  4. 09 11月, 2007 1 次提交
  5. 06 9月, 2007 1 次提交
    • S
      Cleanup unnecessary file modifications in t1400-update-ref · 432e93a1
      Shawn O. Pearce 提交于
      Kristian Høgsberg pointed out that the two file modifications
      we were doing during the 'creating initial files' step are not even
      used within the test suite.  This was actually confusing as we do
      not even need these changes for the tests to pass.  All that really
      matters here is the specific commit dates are used so that these
      appear in the branch's reflog, and that the dates are different so
      that the branch will update when asked and the reflog entry is
      also updated.  There is no need for the file modification.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      432e93a1
  6. 03 7月, 2007 1 次提交
  7. 29 1月, 2007 1 次提交
  8. 20 1月, 2007 1 次提交
    • J
      Extend read_ref_at() to be usable from places other than sha1_name. · 16d7cc90
      Junio C Hamano 提交于
      You can pass an extra argument to the function to receive the
      reflog message information.  Also when the log does not go back
      beyond the point the user asked, the cut-off time and count are
      given back to the caller for emitting the error messages as
      appropriately.
      
      We could later add configuration for get_sha1_basic() to make it
      an error instead of it being just a warning.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      16d7cc90
  9. 16 12月, 2006 1 次提交
    • S
      Enable reflogs by default in any repository with a working directory. · 0bee5918
      Shawn O. Pearce 提交于
      New and experienced Git users alike are finding out too late that
      they forgot to enable reflogs in the current repository, and cannot
      use the information stored within it to recover from an incorrectly
      entered command such as `git reset --hard HEAD^^^` when they really
      meant HEAD^^ (aka HEAD~2).
      
      So enable reflogs by default in all future versions of Git, unless
      the user specifically disables it with:
      
        [core]
          logAllRefUpdates = false
      
      in their .git/config or ~/.gitconfig.
      
      We only enable reflogs in repositories that have a working directory
      associated with them, as shared/bare repositories do not have
      an easy means to prune away old log entries, or may fail logging
      entirely if the user's gecos information is not valid during a push.
      This heuristic was suggested on the mailing list by Junio.
      
      Documentation was also updated to indicate the new default behavior.
      We probably should start to teach usuing the reflog to recover
      from mistakes in some of the tutorial material, as new users are
      likely to make a few along the way and will feel better knowing
      they can recover from them quickly and easily, without fsck-objects'
      lost+found features.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      0bee5918
  10. 18 9月, 2006 1 次提交
  11. 17 9月, 2006 1 次提交
    • J
      t1400: make test debuggable. · 8aac4b45
      Junio C Hamano 提交于
      I had a hard time figuring out why this test was failing with
      the packed-refs update without running it under "sh -x".  This
      makes output from "sh t1400-update-ref.sh -v" more descriptive.
      
      Updating other tests would be a good janitorial task.
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      8aac4b45
  12. 29 7月, 2006 1 次提交
    • S
      Display an error from update-ref if target ref name is invalid. · 818f477c
      Shawn Pearce 提交于
      Alex Riesen (raa.lkml@gmail.com) recently observed that git branch
      would fail with no error message due to unexpected situations with
      regards to refs.  For example, if .git/refs/heads/gu is a file but
      "git branch -b refs/heads/gu/fixa HEAD" was invoked by the user
      it would fail silently due to refs/heads/gu being a file and not
      a directory.
      
      This change adds a test for trying to create a ref within a directory
      that is actually currently a file, and adds error printing within
      the ref locking routine should the resolve operation fail.
      
      The error printing code probably belongs at this level of the library
      as other failures within the ref locking, writing and logging code
      are also currently at this level of the code.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      818f477c
  13. 12 7月, 2006 1 次提交
  14. 11 7月, 2006 1 次提交
    • S
      Record the type of commit operation in the reflog. · a3a733e6
      Shawn Pearce 提交于
      If committing a merge (.git/MERGE_HEAD exists), an initial tree
      (no HEAD) or using --amend to amend the prior commit then denote
      the subtype of commit in the reflog.  This helps to distinguish
      amended or merge commits from normal commits.
      
      In the case of --amend the prior sha1 is probably the commit which
      is being thrown away in favor of the new commit.  Since it is likely
      that the old commit doesn't have any ref pointing to it anymore
      it can be interesting to know why that the commit was replaced
      and orphaned.
      
      In the case of a merge the prior sha1 is probably the first parent
      of the new merge commit.  Consequently having its prior sha1 in the
      reflog is slightly less interesting but its still informative to
      know the commit was the result of a merge which had to be completed
      by hand.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      a3a733e6
  15. 25 5月, 2006 1 次提交
  16. 20 5月, 2006 2 次提交
    • S
      Change 'master@noon' syntax to 'master@{noon}'. · cce91a2c
      Shawn Pearce 提交于
      Its ambiguous to parse "master@2006-05-17 18:30:foo" when foo is
      meant as a file name and ":30" is meant as 30 minutes past 6 pm.
      Therefore all date specifications in a sha1 expression must now
      appear within brackets and the ':' splitter used for the path name
      in a sha1 expression ignores ':' appearing within brackets.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      cce91a2c
    • S
      General ref log reading improvements. · e5229042
      Shawn Pearce 提交于
      Corrected the log starting time displayed in the error message
      (as it was always showing the epoch due to a bad input to strtoul).
      
      Improved the log parser so we only scan backwards towards the
      '\n' from the end of the prior log; during this scan the last '>'
      is remembered to improve performance (rather than scanning forward
      to it).
      
      If the log record matched is the last log record in the file only
      use its new sha1 value if the date matches exactly; otherwise we
      leave the passed in sha1 alone as it already contains the current
      value of the ref.  This way lookups of dates later than the log
      end to stick with the current ref value in case the ref was updated
      without logging.
      
      If it looks like someone changed the ref without logging it and we
      are going to return the sha1 which should have been valid during
      the missing period then warn the user that there might be log data
      missing and thus their query result may not be accurate.  The check
      isn't perfect as its just based on comparing the old and new sha1
      values between the two log records but its better than not checking
      at all.
      
      Implemented test cases based on git-rev-parse for most of the
      boundary conditions.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      e5229042
  17. 18 5月, 2006 1 次提交
    • S
      Log ref updates to logs/refs/<ref> · 6de08ae6
      Shawn Pearce 提交于
      If config parameter core.logAllRefUpdates is true or the log
      file already exists then append a line to ".git/logs/refs/<ref>"
      whenever git-update-ref <ref> is executed.  Each log line contains
      the following information:
      
        oldsha1 <SP> newsha1 <SP> committer <LF>
      
      where committer is the current user, date, time and timezone in
      the standard GIT ident format.  If the caller is unable to append
      to the log file then git-update-ref will fail without updating <ref>.
      
      An optional message may be included in the log line with the -m flag.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <junkio@cox.net>
      6de08ae6