1. 01 12月, 2007 5 次提交
    • L
      Fix a pathological case in git detecting proper renames · 9ae8fcb3
      Linus Torvalds 提交于
      On Thu, 29 Nov 2007, Jeff King wrote:
      >
      > I think it will get worse, because you are simultaneously calculating
      > all of the similarity scores bit by bit rather than doing a loop. Though
      > perhaps you mean at the end you will end up with a list of src/dst pairs
      > sorted by score, and you can loop over that.
      
      Well, after thinking about this a bit, I think there's a solution that may
      work well with the current thing too: instead of looping just *once* over
      the list of rename pairs, loop twice - and simply refuse to do copies on
      the first loop.
      
      This trivial patch does that, and turns Kumar's test-case into a perfect
      rename list.
      
      It's not pretty, it's not smart, but it seems to work. There's something
      to be said for keeping it simple and stupid.
      
      And it should not be nearly as expensive as it may _look_. Yes, the loop
      is "(i = 0; i < num_create * num_src; i++)", but the important part is
      that the whole array is sorted by rename score, and we have a
      
      	if (mx[i].score < minimum_score)
      		break;
      
      in it, so uthe loop actually would tend to terminate rather quickly.
      
      Anyway, Kumar, the thing to take away from this is:
      
       - git really doesn't even *care* about the whole "rename detection"
         internally, and any commits you have done with renames are totally
         independent of the heuristics we then use to *show* the renames.
      
       - the rename detection really is for just two reasons: (a) keep humans
         happy, and keep the diffs small and (b) help automatic merging across
         renames. So getting renames right is certainly good, but it's more of a
         "politeness" issue than a "correctness" issue, although the merge
         portion of it does matter a lot sometimes.
      
       - the important thing here is that you can commit your changes and not
         worry about them being somehow "corrupted" by lack of rename detection,
         even if you commit them with a version of git that doesn't do rename
         detection the way you expected it. The rename detection is an
         "after-the-fact" thing, not something that actually gets saved in the
         repository, which is why we can change the heuristics _after_ seeing
         examples, and the examples magically correct themselves!
      
       - try out the two patches I've posted, and see if they work for you. They
         pass the test-suite, and the output for your example commit looks sane,
         but hey, if you have other test-cases, try them out.
      
      Here's Kumar's pretty diffstat with both my patches:
      
      	 Makefile                                         |    6 +++---
      	 board/{cds => freescale}/common/cadmus.c         |    0
      	 board/{cds => freescale}/common/cadmus.h         |    0
      	 board/{cds => freescale}/common/eeprom.c         |    0
      	 board/{cds => freescale}/common/eeprom.h         |    0
      	 board/{cds => freescale}/common/ft_board.c       |    0
      	 board/{cds => freescale}/common/via.c            |    0
      	 board/{cds => freescale}/common/via.h            |    0
      	 board/{cds => freescale}/mpc8541cds/Makefile     |    0
      	 board/{cds => freescale}/mpc8541cds/config.mk    |    0
      	 board/{cds => freescale}/mpc8541cds/init.S       |    0
      	 board/{cds => freescale}/mpc8541cds/mpc8541cds.c |    0
      	 board/{cds => freescale}/mpc8541cds/u-boot.lds   |    4 ++--
      	 board/{cds => freescale}/mpc8548cds/Makefile     |    0
      	 board/{cds => freescale}/mpc8548cds/config.mk    |    0
      	 board/{cds => freescale}/mpc8548cds/init.S       |    0
      	 board/{cds => freescale}/mpc8548cds/mpc8548cds.c |    0
      	 board/{cds => freescale}/mpc8548cds/u-boot.lds   |    4 ++--
      	 board/{cds => freescale}/mpc8555cds/Makefile     |    0
      	 board/{cds => freescale}/mpc8555cds/config.mk    |    0
      	 board/{cds => freescale}/mpc8555cds/init.S       |    0
      	 board/{cds => freescale}/mpc8555cds/mpc8555cds.c |    0
      	 board/{cds => freescale}/mpc8555cds/u-boot.lds   |    4 ++--
      	 23 files changed, 9 insertions(+), 9 deletions(-)
      
      and here it is before:
      
      	 Makefile                                           |    6 +-
      	 board/cds/mpc8548cds/Makefile                      |   60 -----
      	 board/cds/mpc8555cds/Makefile                      |   60 -----
      	 board/cds/mpc8555cds/init.S                        |  255 --------------------
      	 board/cds/mpc8555cds/u-boot.lds                    |  150 ------------
      	 board/{cds => freescale}/common/cadmus.c           |    0
      	 board/{cds => freescale}/common/cadmus.h           |    0
      	 board/{cds => freescale}/common/eeprom.c           |    0
      	 board/{cds => freescale}/common/eeprom.h           |    0
      	 board/{cds => freescale}/common/ft_board.c         |    0
      	 board/{cds => freescale}/common/via.c              |    0
      	 board/{cds => freescale}/common/via.h              |    0
      	 board/{cds => freescale}/mpc8541cds/Makefile       |    0
      	 board/{cds => freescale}/mpc8541cds/config.mk      |    0
      	 board/{cds => freescale}/mpc8541cds/init.S         |    0
      	 board/{cds => freescale}/mpc8541cds/mpc8541cds.c   |    0
      	 board/{cds => freescale}/mpc8541cds/u-boot.lds     |    4 +-
      	 .../mpc8541cds => freescale/mpc8548cds}/Makefile   |    0
      	 board/{cds => freescale}/mpc8548cds/config.mk      |    0
      	 board/{cds => freescale}/mpc8548cds/init.S         |    0
      	 board/{cds => freescale}/mpc8548cds/mpc8548cds.c   |    0
      	 board/{cds => freescale}/mpc8548cds/u-boot.lds     |    4 +-
      	 .../mpc8541cds => freescale/mpc8555cds}/Makefile   |    0
      	 board/{cds => freescale}/mpc8555cds/config.mk      |    0
      	 .../mpc8541cds => freescale/mpc8555cds}/init.S     |    0
      	 board/{cds => freescale}/mpc8555cds/mpc8555cds.c   |    0
      	 .../mpc8541cds => freescale/mpc8555cds}/u-boot.lds |    4 +-
      	 27 files changed, 9 insertions(+), 534 deletions(-)
      
      so it certainly makes the diffs prettier.
      
      		Linus
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9ae8fcb3
    • L
      Fix a pathological case in git detecting proper renames · 32d75d29
      Linus Torvalds 提交于
      Kumar Gala had a case in the u-boot archive with multiple renames of files
      with identical contents, and git would turn those into multiple "copy"
      operations of one of the sources, and just deleting the other sources.
      
      This patch makes the git exact rename detection prefer to spread out the
      renames over the multiple sources, rather than do multiple copies of one
      source.
      
      NOTE! The changes are a bit larger than required, because I also renamed
      the variables named "one" and "two" to "target" and "source" respectively.
      That makes the logic easier to follow, especially as the "one" was
      illogically the target and not the soruce, for purely historical reasons
      (this piece of code used to traverse over sources and targets in the wrong
      order, and when we fixed that, we didn't fix the names back then. So I
      fixed them now).
      
      The important part of this change is just the trivial score calculations
      for when files have identical contents:
      
      	/* Give higher scores to sources that haven't been used already */
      	score = !source->rename_used;
      	score += basename_same(source, target);
      
      and when we have multiple choices we'll now pick the choice that gets the
      best rename score, rather than only looking at whether the basename
      matched.
      
      It's worth noting a few gotchas:
      
       - this scoring is currently only done for the "exact match" case.
      
         In particular, in Kumar's example, even after this patch, the inexact
         match case is still done as a copy+delete rather than as two renames:
      
      	 delete mode 100644 board/cds/mpc8555cds/u-boot.lds
      	 copy board/{cds => freescale}/mpc8541cds/u-boot.lds (97%)
      	 rename board/{cds/mpc8541cds => freescale/mpc8555cds}/u-boot.lds (97%)
      
         because apparently the "cds/mpc8541cds/u-boot.lds" copy looked
         a bit more similar to both end results. That said, I *suspect* we just
         have the exact same issue there - the similarity analysis just gave
         identical (or at least very _close_ to identical) similarity points,
         and we do not have any logic to prefer multiple renames over a
         copy/delete there.
      
         That is a separate patch.
      
       - When you have identical contents and identical basenames, the actual
         entry that is chosen is still picked fairly "at random" for the first
         one (but the subsequent ones will prefer entries that haven't already
         been used).
      
         It's not actually really random, in that it actually depends on the
         relative alphabetical order of the files (which in turn will have
         impacted the order that the entries got hashed!), so it gives
         consistent results that can be explained. But I wanted to point it out
         as an issue for when anybody actually does cross-renames.
      
         In Kumar's case the choice is the right one (and for a single normal
         directory rename it should always be, since the relative alphabetical
         sorting of the files will be identical), and we now get:
      
      	 rename board/{cds => freescale}/mpc8541cds/init.S (100%)
      	 rename board/{cds => freescale}/mpc8548cds/init.S (100%)
      
         which is the "expected" answer. However, it might still be better to
         change the pedantic "exact same basename" on/off choice into a more
         graduated "how similar are the pathnames" scoring situation, in order
         to be more likely to get the exact rename choice that people *expect*
         to see, rather than other alternatives that may *technically* be
         equally good, but are surprising to a human.
      
      It's also unclear whether we should consider "basenames are equal" or
      "have already used this as a source" to be more important. This gives them
      equal weight, but I suspect we might want to just multiple the "basenames
      are equal" weight by two, or something, to prefer equal basenames even if
      that causes a copy/delete pair. I dunno.
      
      Anyway, what I'm just saying in a really long-winded manner is that I
      think this is right as-is, but it's not the complete solution, and it may
      want some further tweaking in the future.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      32d75d29
    • J
      receive-pack: allow deletion of corrupt refs · 28391a80
      Johannes Schindelin 提交于
      Occasionally, in some setups (*cough* forks on repo.or.cz *cough*) some
      refs go stale, e.g. when the forkee rebased and lost some objects needed
      by the fork.  The quick & dirty way to deal with those refs is to delete
      them and push them again.
      
      However, git-push first would first fetch the current commit name for the
      ref, would receive a null sha1 since the ref does not point to a valid
      object, then tell receive-pack that it should delete the ref with this
      commit name.  delete_ref() would be subsequently be called, and check that
      resolve_ref() (which does _not_ check for validity of the object) returns
      the same commit name.  Which would fail.
      
      The proper fix is to avoid corrupting repositories, but in the meantime
      this is a good fix in any case.
      
      Incidentally, some instances of "cd .." in the test cases were fixed, so
      that subsequent test cases run in t/trash/ irrespective of the outcome of
      the previous test cases.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      28391a80
    • J
      Add config_int() method to the Git perl module · 346d203b
      Jakub Narebski 提交于
      Integer variables can have optional 'k', 'm' or 'g' suffix.
      config_int() method will return simple decimal number, taking
      care of those suffixes.
      Signed-off-by: NJakub Narebski <jnareb@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      346d203b
    • A
  2. 29 11月, 2007 10 次提交
  3. 28 11月, 2007 1 次提交
  4. 27 11月, 2007 2 次提交
  5. 26 11月, 2007 9 次提交
  6. 25 11月, 2007 13 次提交
    • J
      Update draft release notes for 1.5.4 · 92b7ba16
      Junio C Hamano 提交于
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      92b7ba16
    • J
      Merge branch 'maint' · c4316674
      Junio C Hamano 提交于
      * maint:
        Fix rev-list when showing objects involving submodules
        test format-patch -s: make sure MIME content type is shown as needed
        format-patch -s: add MIME encoding header if signer's name requires so
      c4316674
    • J
      Merge branch 'rv/maint-index-commit' into maint · 788ea12d
      Junio C Hamano 提交于
      * rv/maint-index-commit:
        Make GIT_INDEX_FILE apply to git-commit
      788ea12d
    • J
      Merge branch 'lt/maint-rev-list-gitlink' into maint · be4b37b9
      Junio C Hamano 提交于
      * lt/maint-rev-list-gitlink:
        Fix rev-list when showing objects involving submodules
      be4b37b9
    • J
      Merge branch 'jc/maint-add-sync-stat' into maint · bc2b8eaf
      Junio C Hamano 提交于
      * jc/maint-add-sync-stat:
        t2200: test more cases of "add -u"
        git-add: make the entry stat-clean after re-adding the same contents
        ce_match_stat, run_diff_files: use symbolic constants for readability
      bc2b8eaf
    • J
      Merge branch 'jc/maint-format-patch-encoding' into maint · d1c7cd13
      Junio C Hamano 提交于
      * jc/maint-format-patch-encoding:
        test format-patch -s: make sure MIME content type is shown as needed
        format-patch -s: add MIME encoding header if signer's name requires so
      d1c7cd13
    • J
      Merge branch 'bs/maint-t7005' into maint · 18a135f4
      Junio C Hamano 提交于
      * bs/maint-t7005:
        t7005-editor.sh: Don't invoke real vi when it is in GIT_EXEC_PATH
      18a135f4
    • J
      Merge branch 'bs/maint-commit-options' into maint · 89919f4f
      Junio C Hamano 提交于
      * bs/maint-commit-options:
        git-commit: Add tests for invalid usage of -a/--interactive with paths
        git-commit.sh: Fix usage checks regarding paths given when they do not make sense
      89919f4f
    • J
      Deprecate peek-remote · 87194d26
      Junio C Hamano 提交于
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      87194d26
    • J
      t4119: correct overeager war-on-whitespace · 29cc0ef1
      Junio C Hamano 提交于
      Earlier a6080a0a (War on whitespace)
      dropped a necessary trailing whitespace from the test vector.
      29cc0ef1
    • J
      Merge branch 'jk/send-pack' · fd200790
      Junio C Hamano 提交于
      * jk/send-pack: (24 commits)
        send-pack: cluster ref status reporting
        send-pack: fix "everything up-to-date" message
        send-pack: tighten remote error reporting
        make "find_ref_by_name" a public function
        Fix warning about bitfield in struct ref
        send-pack: assign remote errors to each ref
        send-pack: check ref->status before updating tracking refs
        send-pack: track errors for each ref
        git-push: add documentation for the newly added --mirror mode
        Add tests for git push'es mirror mode
        Update the tracking references only if they were succesfully updated on remote
        Add a test checking if send-pack updated local tracking branches correctly
        git-push: plumb in --mirror mode
        Teach send-pack a mirror mode
        send-pack: segfault fix on forced push
        Reteach builtin-ls-remote to understand remotes
        send-pack: require --verbose to show update of tracking refs
        receive-pack: don't mention successful updates
        more terse push output
        Build in ls-remote
        ...
      fd200790
    • J
      Merge branch 'sb/clean' · 6c6ea380
      Junio C Hamano 提交于
      * sb/clean:
        Teach git clean to use setup_standard_excludes()
        git-clean: Fix error message if clean.requireForce is not set.
        Make git-clean a builtin
      6c6ea380
    • J
      Merge branch 'js/mingw-fallouts' · ab002e34
      Junio C Hamano 提交于
      * js/mingw-fallouts:
        fetch-pack: Prepare for a side-band demultiplexer in a thread.
        rehabilitate some t5302 tests on 32-bit off_t machines
        Allow ETC_GITCONFIG to be a relative path.
        Introduce git_etc_gitconfig() that encapsulates access of ETC_GITCONFIG.
        Allow a relative builtin template directory.
        Close files opened by lock_file() before unlinking.
        builtin run_command: do not exit with -1.
        Move #include <sys/select.h> and <sys/ioctl.h> to git-compat-util.h.
        Use is_absolute_path() in sha1_file.c.
        Skip t3902-quoted.sh if the file system does not support funny names.
        t5302-pack-index: Skip tests of 64-bit offsets if necessary.
        t7501-commit.sh: Not all seds understand option -i
        t5300-pack-object.sh: Split the big verify-pack test into smaller parts.
      ab002e34