1. 21 3月, 2012 1 次提交
    • J
      merge: backport GIT_MERGE_AUTOEDIT support · d387868a
      Junio C Hamano 提交于
      Even though 1.7.9.x series does not open the editor by default
      when merging in general, it does do so in one occassion: when
      merging an annotated tag. And worse yet, there is no good way
      for older scripts to decline this.
      
      Backport the support for GIT_MERGE_AUTOEDIT environment variable
      from 1.7.10 track to help those stuck on 1.7.9.x maintenance
      track.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d387868a
  2. 29 2月, 2012 2 次提交
  3. 28 2月, 2012 1 次提交
  4. 20 2月, 2012 1 次提交
  5. 14 2月, 2012 3 次提交
  6. 10 2月, 2012 1 次提交
  7. 09 2月, 2012 1 次提交
    • J
      tag: do not show non-tag contents with "-n" · 31fd8d72
      Junio C Hamano 提交于
      "git tag -n" did not check the type of the object it is reading the top n
      lines from. At least, avoid showing the beginning of trees and blobs when
      dealing with lightweight tags that point at them.
      
      As the payload of a tag and a commit look similar in that they both start
      with a header block, which is skipped for the purpose of "-n" output,
      followed by human readable text, allow the message of commit objects to be
      shown just like the contents of tag objects. This avoids regression for
      people who have been using "tag -n" to show the log messages of commits
      that are pointed at by lightweight tags.
      
      Test script is from Jeff King.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      31fd8d72
  8. 08 2月, 2012 1 次提交
    • J
      add -e: do not show difference in a submodule that is merely dirty · 701825de
      Johannes Schindelin 提交于
      When the HEAD of the submodule matches what is recorded in the index of
      the superproject, and it has local changes or untracked files, the patch
      offered by "git add -e" for editing shows a diff like this:
      
          diff --git a/submodule b/submodule
          <header>
          -deadbeef...
          +deadbeef...-dirty
      
      Because applying such a patch has no effect to the index, this is a
      useless noise.  Generate the patch with IGNORE_DIRTY_SUBMODULES flag to
      prevent such a change from getting reported.
      
      This patch also loses the "-dirty" suffix from the output when the HEAD of
      the submodule is different from what is in the index of the superproject.
      As such dirtiness expressed by the suffix does not affect the result of
      the patch application at all, there is no information lost if we remove
      it. The user could still run "git status" before "git add -e" if s/he
      cares about the dirtiness.
      Signed-off-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      701825de
  9. 07 2月, 2012 3 次提交
    • J
      git checkout -b: allow switching out of an unborn branch · abe19980
      Junio C Hamano 提交于
      Running "git checkout -b another" immediately after "git init" when you do
      not even have a commit on 'master' fails with:
      
          $ git checkout -b another
          fatal: You are on a branch yet to be born
      
      This is unnecessary, if we redefine "git checkout -b $name" that does not
      take any $start_point (which has to be a commit) as "I want to check out a
      new branch $name from the state I am in".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      abe19980
    • J
      tag: die when listing missing or corrupt objects · fb630e04
      Jeff King 提交于
      We don't usually bother looking at tagged objects at all
      when listing. However, if "-n" is specified, we open the
      objects to read the annotations of the tags.  If we fail to
      read an object, or if the object has zero length, we simply
      silently return.
      
      The first case is an indication of a broken or corrupt repo,
      and we should notify the user of the error.
      
      The second case is OK to silently ignore; however, the
      existing code leaked the buffer returned by read_sha1_file.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      fb630e04
    • J
      tag: fix output of "tag -n" when errors occur · ca516999
      Jeff King 提交于
      When "git tag" is instructed to print lines from annotated
      tags via "-n", it first prints the tag name, then attempts
      to parse and print the lines of the tag object, and then
      finally adds a trailing newline.
      
      If an error occurs, we return early from the function and
      never print the newline, screwing up the output for the next
      tag. Let's factor the line-printing into its own function so
      we can manage the early returns better, and make sure that
      we always terminate the line.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ca516999
  10. 06 2月, 2012 2 次提交
    • J
      branch --edit-description: protect against mistyped branch name · c2d17ba3
      Junio C Hamano 提交于
      It is very easy to mistype the branch name when editing its description,
      e.g.
      
      	$ git checkout -b my-topic master
      	: work work work
      	: now we are at a good point to switch working something else
      	$ git checkout master
      	: ah, let's write it down before we forget what we were doing
      	$ git branch --edit-description my-tpoic
      
      The command does not notice that branch 'my-tpoic' does not exist.  It is
      not lost (it becomes description of an unborn my-tpoic branch), but is not
      very useful.  So detect such a case and error out to reduce the grief
      factor from this common mistake.
      
      This incidentally also errors out --edit-description when the HEAD points
      at an unborn branch (immediately after "init", or "checkout --orphan"),
      because at that point, you do not even have any commit that is part of
      your history and there is no point in describing how this particular
      branch is different from the branch it forked off of, which is the useful
      bit of information the branch description is designed to capture.
      
      We may want to special case the unborn case later, but that is outside the
      scope of this patch to prevent more common mistakes before 1.7.9 series
      gains too much widespread use.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      c2d17ba3
    • J
      merge: do not create a signed tag merge under --ff-only option · b5c9f1c1
      Junio C Hamano 提交于
      Starting at release v1.7.9, if you ask to merge a signed tag, "git merge"
      always creates a merge commit, even when the tag points at a commit that
      happens to be a descendant of your current commit.
      
      Unfortunately, this interacts rather badly for people who use --ff-only to
      make sure that their branch is free of local developments. It used to be
      possible to say:
      
      	$ git checkout -b frotz v1.7.9~30
              $ git merge --ff-only v1.7.9
      
      and expect that the resulting tip of frotz branch matches v1.7.9^0 (aka
      the commit tagged as v1.7.9), but this fails with the updated Git with:
      
      	fatal: Not possible to fast-forward, aborting.
      
      because a merge that merges v1.7.9 tag to v1.7.9~30 cannot be created by
      fast forwarding.
      
      We could teach users that now they have to do
      
      	$ git merge --ff-only v1.7.9^0
      
      but it is far more pleasant for users if we DWIMmed this ourselves.
      
      When an integrator pulls in a topic from a lieutenant via a signed tag,
      even when the work done by the lieutenant happens to fast-forward, the
      integrator wants to have a merge record, so the integrator will not be
      asking for --ff-only when running "git pull" in such a case. Therefore,
      this change should not regress the support for the use case v1.7.9 wanted
      to add.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b5c9f1c1
  11. 04 2月, 2012 2 次提交
    • N
      Use correct grammar in diffstat summary line · 7f814632
      Nguyễn Thái Ngọc Duy 提交于
      "git diff --stat" and "git apply --stat" now learn to print the line
      "%d files changed, %d insertions(+), %d deletions(-)" in singular form
      whenever applicable. "0 insertions" and "0 deletions" are also omitted
      unless they are both zero.
      
      This matches how versions of "diffstat" that are not prehistoric produced
      their output, and also makes this line translatable.
      
      [jc: with help from Thomas Dickey in archaeology of "diffstat"]
      [jc: squashed Jonathan's updates to illustrations in tutorials and a test]
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      7f814632
    • J
      parse_date(): '@' prefix forces git-timestamp · 2c733fb2
      Junio C Hamano 提交于
      The only place that the issue this series addresses was observed
      where we read "cat-file commit" output and put it in GIT_AUTHOR_DATE
      in order to replay a commit with an ancient timestamp.
      
      With the previous patch alone, "git commit --date='20100917 +0900'"
      can be misinterpreted to mean an ancient timestamp, not September in
      year 2010.  Guard this codepath by requring an extra '@' in front of
      the raw git timestamp on the parsing side. This of course needs to
      be compensated by updating get_author_ident_from_commit and the code
      for "git commit --amend" to prepend '@' to the string read from the
      existing commit in the GIT_AUTHOR_DATE environment variable.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2c733fb2
  12. 03 2月, 2012 5 次提交
    • J
      standardize and improve lookup rules for external local repos · b3256eb8
      Jeff King 提交于
      When you specify a local repository on the command line of
      clone, ls-remote, upload-pack, receive-pack, or upload-archive,
      or in a request to git-daemon, we perform a little bit of
      lookup magic, doing things like looking in working trees for
      .git directories and appending ".git" for bare repos.
      
      For clone, this magic happens in get_repo_path. For
      everything else, it happens in enter_repo. In both cases,
      there are some ambiguous or confusing cases that aren't
      handled well, and there is one case that is not handled the
      same by both methods.
      
      This patch tries to provide (and test!) standard, sensible
      lookup rules for both code paths. The intended changes are:
      
        1. When looking up "foo", we have always preferred
           a working tree "foo" (containing "foo/.git" over the
           bare "foo.git". But we did not prefer a bare "foo" over
           "foo.git". With this patch, we do so.
      
        2. We would select directories that existed but didn't
           actually look like git repositories. With this patch,
           we make sure a selected directory looks like a git
           repo. Not only is this more sensible in general, but it
           will help anybody who is negatively affected by change
           (1) negatively (e.g., if they had "foo.git" next to its
           separate work tree "foo", and expect to keep finding
           "foo.git" when they reference "foo").
      
        3. The enter_repo code path would, given "foo", look for
           "foo.git/.git" (i.e., do the ".git" append magic even
           for a repo with working tree). The clone code path did
           not; with this patch, they now behave the same.
      
      In the unlikely case of a working tree overlaying a bare
      repo (i.e., a ".git" directory _inside_ a bare repo), we
      continue to treat it as a working tree (prefering the
      "inner" .git over the bare repo). This is mainly because the
      combination seems nonsensical, and I'd rather stick with
      existing behavior on the off chance that somebody is relying
      on it.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b3256eb8
    • J
      grep: pre-load userdiff drivers when threaded · 9dd5245c
      Jeff King 提交于
      The low-level grep_source code will automatically load the
      userdiff driver to see whether a file is binary. However,
      when we are threaded, it will load the drivers in a
      non-deterministic order, handling each one as its assigned
      thread happens to be scheduled.
      
      Meanwhile, the attribute lookup code (which underlies the
      userdiff driver lookup) is optimized to handle paths in
      sequential order (because they tend to share the same
      gitattributes files). Multi-threading the lookups destroys
      the locality and makes this optimization less effective.
      
      We can fix this by pre-loading the userdiff driver in the
      main thread, before we hand off the file to a worker thread.
      My best-of-five for "git grep foo" on the linux-2.6
      repository went from:
      
        real    0m0.391s
        user    0m1.708s
        sys     0m0.584s
      
      to:
      
        real    0m0.360s
        user    0m1.576s
        sys     0m0.572s
      
      Not a huge speedup, but it's quite easy to do. The only
      trick is that we shouldn't perform this optimization if "-a"
      was used, in which case we won't bother checking whether
      the files are binary at all.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9dd5245c
    • J
      convert git-grep to use grep_source interface · 8f24a632
      Jeff King 提交于
      The grep_source interface (as opposed to grep_buffer) will
      eventually gives us a richer interface for telling the
      low-level grep code about our buffers. Eventually this will
      lead to things like better binary-file handling. For now, it
      lets us drop a lot of now-redundant code.
      
      The conversion is mostly straight-forward. One thing to note
      is that the memory ownership rules for "struct grep_source"
      are different than the "struct work_item" found here (the
      former will copy things like the filename, rather than
      taking ownership). Therefore you will also see some slight
      tweaking of when filename buffers are released.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8f24a632
    • J
      grep: move sha1-reading mutex into low-level code · b3aeb285
      Jeff King 提交于
      The multi-threaded git-grep code needs to serialize access
      to the thread-unsafe read_sha1_file call. It does this with
      a mutex that is local to builtin/grep.c.
      
      Let's instead push this down into grep.c, where it can be
      used by both builtin/grep.c and grep.c. This will let us
      safely teach the low-level grep.c code tricks that involve
      reading from the object db.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b3aeb285
    • J
      grep: make locking flag global · 78db6ea9
      Jeff King 提交于
      The low-level grep code traditionally didn't care about
      threading, as it doesn't do any threading itself and didn't
      call out to other non-thread-safe code.  That changed with
      0579f91d (grep: enable threading with -p and -W using lazy
      attribute lookup, 2011-12-12), which pushed the lookup of
      funcname attributes (which is not thread-safe) into the
      low-level grep code.
      
      As a result, the low-level code learned about a new global
      "grep_attr_mutex" to serialize access to the attribute code.
      A multi-threaded caller (e.g., builtin/grep.c) is expected
      to initialize the mutex and set "use_threads" in the
      grep_opt structure. The low-level code only uses the lock if
      use_threads is set.
      
      However, putting the use_threads flag into the grep_opt
      struct is not the most logical place. Whether threading is
      in use is not something that matters for each call to
      grep_buffer, but is instead global to the whole program
      (i.e., if any thread is doing multi-threaded grep, every
      other thread, even if it thinks it is doing its own
      single-threaded grep, would need to use the locking).  In
      practice, this distinction isn't a problem for us, because
      the only user of multi-threaded grep is "git-grep", which
      does nothing except call grep.
      
      This patch turns the opt->use_threads flag into a global
      flag. More important than the nit-picking semantic argument
      above is that this means that the locking functions don't
      need to actually have access to a grep_opt to know whether
      to lock. Which in turn can make adding new locks simpler, as
      we don't need to pass around a grep_opt.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      78db6ea9
  13. 02 2月, 2012 1 次提交
  14. 01 2月, 2012 1 次提交
    • T
      merge: add instructions to the commit message when editing · f26af3fc
      Thomas Rast 提交于
      Before f8246281 (merge: use editor by default in interactive sessions,
      2012-01-10), git-merge only started an editor if the user explicitly
      asked for it with --edit.  Thus it seemed unlikely that the user would
      need extra guidance.
      
      After f8246281 the _normal_ thing is to start an editor.  Give at least
      an indication of why we are doing it.
      
      The sentence about justification is one of the few things about
      standard git that are not agnostic to the workflow that the user
      chose.  However, f8246281 was proposed by Linus specifically to
      discourage users from merging unrelated upstream progress into topic
      branches.  So we may as well take another step in the same direction.
      Signed-off-by: NThomas Rast <trast@student.ethz.ch>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      f26af3fc
  15. 24 1月, 2012 1 次提交
  16. 13 1月, 2012 1 次提交
    • J
      thin-pack: try harder to use preferred base objects as base · 15f07e06
      Jeff King 提交于
      When creating a pack using objects that reside in existing packs, we try
      to avoid recomputing futile delta between an object (trg) and a candidate
      for its base object (src) if they are stored in the same packfile, and trg
      is not recorded as a delta already. This heuristics makes sense because it
      is likely that we tried to express trg as a delta based on src but it did
      not produce a good delta when we created the existing pack.
      
      As the pack heuristics prefer producing delta to remove data, and Linus's
      law dictates that the size of a file grows over time, we tend to record
      the newest version of the file as inflated, and older ones as delta
      against it.
      
      When creating a thin-pack to transfer recent history, it is likely that we
      will try to send an object that is recorded in full, as it is newer.  But
      the heuristics to avoid recomputing futile delta effectively forbids us
      from attempting to express such an object as a delta based on another
      object. Sending an object in full is often more expensive than sending a
      suboptimal delta based on other objects, and it is even more so if we
      could use an object we know the receiving end already has (i.e. preferred
      base object) as the delta base.
      
      Tweak the recomputation avoidance logic, so that we do not punt on
      computing delta against a preferred base object.
      
      The effect of this change can be seen on two simulated upload-pack
      workloads. The first is based on 44 reflog entries from my git.git
      origin/master reflog, and represents the packs that kernel.org sent me git
      updates for the past month or two. The second workload represents much
      larger fetches, going from git's v1.0.0 tag to v1.1.0, then v1.1.0 to
      v1.2.0, and so on.
      
      The table below shows the average generated pack size and the average CPU
      time consumed for each dataset, both before and after the patch:
      
                        dataset
                  | reflog | tags
      ---------------------------------
           before | 53358  | 2750977
      size  after | 32398  | 2668479
           change |   -39% |      -3%
      ---------------------------------
           before |  0.18  | 1.12
      CPU   after |  0.18  | 1.15
           change |    +0% |      +3%
      
      This patch makes a much bigger difference for packs with a shorter slice
      of history (since its effect is seen at the boundaries of the pack) though
      it has some benefit even for larger packs.
      Signed-off-by: NJeff King <peff@peff.net>
      Acked-by: NNicolas Pitre <nico@fluxnic.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      15f07e06
  17. 09 1月, 2012 2 次提交
  18. 07 1月, 2012 3 次提交
  19. 06 1月, 2012 1 次提交
  20. 04 1月, 2012 1 次提交
    • J
      write first for-merge ref to FETCH_HEAD first · 96890f4c
      Joey Hess 提交于
      The FETCH_HEAD refname is supposed to refer to the ref that was fetched
      and should be merged. However all fetched refs are written to
      .git/FETCH_HEAD in an arbitrary order, and resolve_ref_unsafe simply
      takes the first ref as the FETCH_HEAD, which is often the wrong one,
      when other branches were also fetched.
      
      The solution is to write the for-merge ref(s) to FETCH_HEAD first.
      Then, unless --append is used, the FETCH_HEAD refname behaves as intended.
      If the user uses --append, they presumably are doing so in order to
      preserve the old FETCH_HEAD.
      
      While we are at it, update an old example in the read-tree documentation
      that implied that each entry in FETCH_HEAD only has the object name, which
      is not true for quite a while.
      
      [jc: adjusted tests]
      Signed-off-by: NJoey Hess <joey@kitenet.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      96890f4c
  21. 28 12月, 2011 1 次提交
  22. 23 12月, 2011 1 次提交
    • J
      i18n of multi-line advice messages · 23cb5bf3
      Junio C Hamano 提交于
      Advice messages are by definition meant for human end-users, and prime
      candidates for i18n/l10n. They tend to also be more verbose to be helpful,
      and need to be longer than just one line.
      
      Although we do not have parameterized multi-line advice messages yet, once
      we do, we cannot emit such a message like this:
      
          advise(_("Please rename %s to something else"), gostak);
          advise(_("so that we can avoid distimming %s unnecessarily."), doshes);
      
      because some translations may need to have the replacement of 'gostak' on
      the second line (or 'doshes' on the first line). Some languages may even
      need to use three lines in order to fit the same message within a
      reasonable width.
      
      Instead, it has to be a single advise() construct, like this:
      
          advise(_("Please rename %s to something else\n"
                   "so that we can avoid distimming %s unnecessarily."),
                 gostak, doshes);
      
      Update the advise() function and its existing callers to
      
       - take a format string that can be multi-line and translatable as a
         whole;
       - use the string and the parameters to form a localized message; and
       - show each line in the result with the localization of the "hint: ".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      23cb5bf3
  23. 22 12月, 2011 4 次提交