1. 19 3月, 2008 1 次提交
  2. 01 3月, 2008 1 次提交
  3. 25 2月, 2008 2 次提交
  4. 23 2月, 2008 1 次提交
    • J
      Avoid unnecessary "if-before-free" tests. · 8e0f7003
      Jim Meyering 提交于
      This change removes all obvious useless if-before-free tests.
      E.g., it replaces code like this:
      
              if (some_expression)
                      free (some_expression);
      
      with the now-equivalent:
      
              free (some_expression);
      
      It is equivalent not just because POSIX has required free(NULL)
      to work for a long time, but simply because it has worked for
      so long that no reasonable porting target fails the test.
      Here's some evidence from nearly 1.5 years ago:
      
          http://www.winehq.org/pipermail/wine-patches/2006-October/031544.html
      
      FYI, the change below was prepared by running the following:
      
        git ls-files -z | xargs -0 \
        perl -0x3b -pi -e \
          's/\bif\s*\(\s*(\S+?)(?:\s*!=\s*NULL)?\s*\)\s+(free\s*\(\s*\1\s*\))/$2/s'
      
      Note however, that it doesn't handle brace-enclosed blocks like
      "if (x) { free (x); }".  But that's ok, since there were none like
      that in git sources.
      
      Beware: if you do use the above snippet, note that it can
      produce syntactically invalid C code.  That happens when the
      affected "if"-statement has a matching "else".
      E.g., it would transform this
      
        if (x)
          free (x);
        else
          foo ();
      
      into this:
      
        free (x);
        else
          foo ();
      
      There were none of those here, either.
      
      If you're interested in automating detection of the useless
      tests, you might like the useless-if-before-free script in gnulib:
      [it *does* detect brace-enclosed free statements, and has a --name=S
       option to make it detect free-like functions with different names]
      
        http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=blob;f=build-aux/useless-if-before-free
      
      Addendum:
        Remove one more (in imap-send.c), spotted by Jean-Luc Herren <jlh@gmx.ch>.
      Signed-off-by: NJim Meyering <meyering@redhat.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      8e0f7003
  5. 21 2月, 2008 1 次提交
    • D
      Resolve value supplied for no-colon push refspecs · 9f0ea7e8
      Daniel Barkalow 提交于
      When pushing a refspec like "HEAD", we used to treat it as
      "HEAD:HEAD", which didn't work without rewriting. Instead, we should
      resolve the ref. If it's a symref, further require it to point to a
      branch, to avoid doing anything especially unexpected. Also remove the
      rewriting previously added in builtin-push.
      
      Since the code for "HEAD" uses the regular refspec parsing, it
      automatically handles "+HEAD" without anything special.
      
      [jc: added a further test to make sure that "remote.*.push = HEAD" works]
      Signed-off-by: NDaniel Barkalow <barkalow@iabervon.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9f0ea7e8
  6. 19 2月, 2008 1 次提交
  7. 16 2月, 2008 1 次提交
  8. 12 2月, 2008 1 次提交
  9. 15 12月, 2007 1 次提交
  10. 04 12月, 2007 1 次提交
  11. 19 11月, 2007 2 次提交
    • S
      refactor fetch's ref matching to use refname_match() · 605b4978
      Steffen Prohaska 提交于
      The old rules used by fetch were coded as a series of ifs.  The old
      rules are:
      1) match full refname if it starts with "refs/" or matches "HEAD"
      2) verify that full refname starts with "refs/"
      3) match abbreviated name in "refs/" if it starts with "heads/",
          "tags/", or "remotes/".
      4) match abbreviated name in "refs/heads/"
      
      This is replaced by the new rules
      a) match full refname
      b) match abbreviated name prefixed with "refs/"
      c) match abbreviated name prefixed with "refs/heads/"
      
      The details of the new rules are different from the old rules.  We no
      longer verify that the full refname starts with "refs/".  The new rule
      (a) matches any full string.  The old rules (1) and (2) were stricter.
      Now, the caller is responsible for using sensible full refnames.  This
      should be the case for the current code.  The new rule (b) is less
      strict than old rule (3).  The new rule accepts abbreviated names that
      start with a non-standard prefix below "refs/".
      
      Despite this modifications the new rules should handle all cases as
      expected.  Two tests are added to verify that fetch does not resolve
      short tags or HEAD in remotes.
      
      We may even think about loosening the rules a bit more and unify them
      with the rev-parse rules.  This would be done by replacing
      ref_ref_fetch_rules with ref_ref_parse_rules.  Note, the two new test
      would break.
      Signed-off-by: NSteffen Prohaska <prohaska@zib.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      605b4978
    • S
      push: use same rules as git-rev-parse to resolve refspecs · ae36bdcf
      Steffen Prohaska 提交于
      This commit changes the rules for resolving refspecs to match the
      rules for resolving refs in rev-parse. git-rev-parse uses clear rules
      to resolve a short ref to its full name, which are well documented.
      The rules for resolving refspecs documented in git-send-pack were
      less strict and harder to understand. This commit replaces them by
      the rules of git-rev-parse.
      
      The unified rules are easier to understand and better resolve ambiguous
      cases. You can now push from a repository containing several branches
      ending on the same short name.
      
      Note, this may break existing setups. For example, "master" will no longer
      resolve to "origin/master" even when there is no other "master" elsewhere.
      Signed-off-by: NSteffen Prohaska <prohaska@zib.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ae36bdcf
  12. 18 11月, 2007 1 次提交
  13. 10 11月, 2007 1 次提交
    • A
      Teach send-pack a mirror mode · 28b9d6e5
      Andy Whitcroft 提交于
      Existing "git push --all" is almost perfect for backing up to
      another repository, except that "--all" only means "all
      branches" in modern git, and it does not delete old branches and
      tags that exist at the back-up repository that you have removed
      from your local repository.
      
      This teaches "git-send-pack" a new "--mirror" option.  The
      difference from the "--all" option are that (1) it sends all
      refs, not just branches, and (2) it deletes old refs you no
      longer have on the local side from the remote side.
      
      Original patch by Junio C Hamano.
      Signed-off-by: NAndy Whitcroft <apw@shadowen.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      28b9d6e5
  14. 03 11月, 2007 1 次提交
    • D
      Miscellaneous const changes and utilities · 4577370e
      Daniel Barkalow 提交于
      The list of remote refs in struct transport should be const, because
      builtin-fetch will get confused if it changes.
      
      The url in git_connect should be const (and work on a copy) instead of
      requiring the caller to copy it.
      
      match_refs doesn't modify the refspecs it gets.
      
      get_fetch_map and get_remote_ref don't change the list they get.
      
      Allow transport get_refs_list methods to modify the struct transport.
      
      Add a function to copy a list of refs, when a function needs a mutable
      copy of a const list.
      
      Add a function to check the type of a ref, as per the code in connect.c
      Signed-off-by: NDaniel Barkalow <barkalow@iabervon.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4577370e
  15. 31 10月, 2007 1 次提交
  16. 29 10月, 2007 1 次提交
    • J
      git-fetch: do not fail when remote branch disappears · 9ad7c5ae
      Junio C Hamano 提交于
      When the branch named with branch.$name.merge is not covered by
      the fetch configuration for the remote repository named with
      branch.$name.remote, we automatically add that branch to the set
      of branches to be fetched.  However, if the remote repository
      does not have that branch (e.g. it used to exist, but got
      removed), this is not a reason to fail the git-fetch itself.
      
      The situation however will be noticed if git-fetch was called by
      git-pull, as the resulting FETCH_HEAD would not have any entry
      that is marked for merging.
      Acked-By: NDaniel Barkalow <barkalow@iabervon.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      9ad7c5ae
  17. 20 10月, 2007 1 次提交
  18. 16 10月, 2007 2 次提交
  19. 25 9月, 2007 3 次提交
  20. 19 9月, 2007 7 次提交
    • S
      Rename remote.uri to remote.url within remote handling internals · 28b91f8a
      Shawn O. Pearce 提交于
      Anyplace we talk about the address of a remote repository we always
      refer to it as a URL, especially in the configuration file and
      .git/remotes where we call it "remote.$n.url" or start the first
      line with "URL:".  Calling this value a uri within the internal C
      code just doesn't jive well with our commonly accepted terms.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      28b91f8a
    • S
      Correct handling of branch.$name.merge in builtin-fetch · 85682c19
      Shawn O. Pearce 提交于
      My prior bug fix for git-push titled "Don't configure remote "." to
      fetch everything to itself" actually broke t5520 as we were unable
      to evaluate a branch configuration of:
      
        [branch "copy"]
          remote = .
          merge = refs/heads/master
      
      as remote "." did not have a "remote...fetch" configuration entry to
      offer up refs/heads/master as a possible candidate available to be
      fetched and merged.  In shell script git-fetch and prior to the above
      mentioned commit this was hardcoded for a url of "." to be the set of
      local branches.
      
      Chasing down this bug led me to the conclusion that our prior behavior
      with regards to branch.$name.merge was incorrect.  In the shell script
      based git-fetch implementation we only fetched and merged a branch if
      it appeared both in branch.$name.merge *and* in remote.$r.fetch, where
      $r = branch.$name.remote.  In other words in the following config file:
      
        [remote "origin"]
          url = git://git.kernel.org/pub/scm/git/git.git
          fetch = refs/heads/master:refs/remotes/origin/master
        [branch "master"]
          remote = origin
          merge = refs/heads/master
        [branch "pu"]
          remote = origin
          merge = refs/heads/pu
      
      Attempting to run `git pull` while on branch "pu" would always give
      the user "Already up-to-date" as git-fetch did not fetch pu and thus
      did not mark it for merge in .git/FETCH_HEAD.  The configured merge
      would always be ignored and the user would be left scratching her
      confused head wondering why merge did not work on "pu" but worked
      fine on "master".
      
      If we are using the "default fetch" specification for the current
      branch and the current branch has a branch.$name.merge configured
      we now union it with the list of refs in remote.$r.fetch.  This
      way the above configuration does what the user expects it to do,
      which is to fetch only "master" by default but when on "pu" to
      fetch both "master" and "pu".
      
      This uncovered some breakage in the test suite where old-style Cogito
      branches (.git/branches/$r) did not fetch the branches listed in
      .git/config for merging and thus did not actually merge them if the
      user tried to use `git pull` on that branch.  Junio and I discussed
      it on list and felt that the union approach here makes more sense to
      DWIM for the end-user than silently ignoring their configured request
      so the test vectors for t5515 have been updated to include for-merge
      lines in .git/FETCH_HEAD where they have been configured for-merge
      in .git/config.
      
      Since we are now performing a union of the fetch specification and
      the merge specification and we cannot allow a branch to be listed
      twice (otherwise it comes out twice in .git/FETCH_HEAD) we need to
      perform a double loop here over all of the branch.$name.merge lines
      and try to set their merge flag if we have already schedule that
      branch for fetching by remote.$r.fetch.  If no match is found then
      we must add new specifications to fetch the branch but not store it
      as no local tracking branch has been designated.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      85682c19
    • S
      builtin-fetch: Don't segfault on "fetch +foo" · 27e13374
      Shawn O. Pearce 提交于
      If we are fetching something and were configured to do a forced
      fetch and have no local ref to store the fetched object into we
      cannot mark the local ref as having a forced update.  Instead we
      should just silently discard the + request.
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      27e13374
    • S
      Don't configure remote "." to fetch everything to itself · ad23603c
      Shawn O. Pearce 提交于
      When we are talking about a remote URI of "." we are really talking
      about *this* repository that we are fetching into or pushing out of.
      There are no matching tracking branches for this repository; we
      do not attempt to map a ref back to ourselves as this would either
      create an infinite cycle (for example "fetch = +refs/*:refs/mine/*")
      or it causes problems when we attempt to push back to ourselves.
      
      So we really cannot setup a remote like this:
      
        [remote "."]
          url = .
          fetch = +refs/*:refs/*
      
      In the case of `git push . B:T` to fast-forward branch T to B's
      current commit git-send-pack will update branch T to B, assuming that
      T is the remote tracking branch for B.  This update is performed
      immediately before git-send-pack asks git-receive-pack to perform
      the same update, and git-receive-pack then fails because T is not
      where git-send-pack told it to expect T to be at.
      
      In the case of `git fetch .` we really should do the same thing as
      `git fetch $otherrepo`, that is load .git/FETCH_HEAD with the commit
      of HEAD, so that `git pull .` will report "Already up-to-date".
      We have always behaved like this before on this insane request and
      we should at least continue to behave the same way.  With the above
      (bad) remote configuration we were instead getting fetch errors
      about funny refs, e.g. "refs/stash".
      Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ad23603c
    • D
      Add matching and parsing for fetch-side refspec rules · d71ab174
      Daniel Barkalow 提交于
      Also exports parse_ref_spec().
      Signed-off-by: NDaniel Barkalow <barkalow@iabervon.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d71ab174
    • D
      Report information on branches from remote.h · cf818348
      Daniel Barkalow 提交于
      This adds full parsing for branch.<name> sections and functions to
      interpret the results usefully. It incidentally corrects the fetch
      configuration information for legacy branches/* files with '#'
      characters in the URLs.
      Signed-off-by: NDaniel Barkalow <barkalow@iabervon.org>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      cf818348
    • D
      0012ba21
  21. 12 7月, 2007 1 次提交
  22. 10 7月, 2007 2 次提交
  23. 03 7月, 2007 1 次提交
    • J
      "git-push $URL" without refspecs pushes only matching branches · 098e711e
      Junio C Hamano 提交于
      When "git push" is run without any refspec (neither on the
      command line nor in the config), we used to push "matching refs"
      in the sense that anything under refs/ hierarchy that exist on
      both ends were updated.  This used to be a sane default for
      publishing your repository to another back when we did not have
      refs/remotes/ hierarchy, but it does not make much sense these
      days.
      
      This changes the semantics to push only "matching branches".
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      098e711e
  24. 16 6月, 2007 1 次提交
  25. 13 6月, 2007 1 次提交
  26. 10 6月, 2007 3 次提交
    • J
      remote.c: "git-push frotz" should update what matches at the source. · 1ed10b88
      Junio C Hamano 提交于
      Earlier, when the local repository has a branch "frotz" and the
      remote repository has a tag "frotz" (but not branch "frotz"),
      "git-push frotz" mistakenly updated the tag at the remote side.
      This was because the partial refname matching code was applied
      independently on both source and destination side.
      
      With this fix, when a colon-less refspec is given to git-push,
      we first match it with the refs in the source repository, and
      update the matching ref in the destination repository.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1ed10b88
    • J
      remote.c: fix "git push" weak match disambiguation · 6125796f
      Junio C Hamano 提交于
      When "git push A:B" is given, and A (or B) is not a full refname
      that begins with refs/, we require an unambiguous match with an
      existing ref.  For this purpose, a match with a local branch or
      a tag (i.e. refs/heads/A and refs/tags/A) is called a "strong
      match", and any other match is called a "weak match".  A partial
      refname is unambiguous when there is only one strong match with
      any number of weak matches, or when there is only one weak match
      and no other match.
      
      However, as reported by Sparse with Ramsay Jones recently,
      count_refspec_match() function had a bug where a variable in an
      inner block masked a different variable of the same name, which
      caused the weak matches to be ignored.
      
      This fixes it, and adds tests for the fix.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      6125796f
    • J
      remote.c: minor clean-up of match_explicit() · 3c8b7df1
      Junio C Hamano 提交于
      When checking what ref the source refspec matches, we have no
      business setting the default for the destination, so move that
      code lower.  Also simplify the result from the code block that
      matches the source side by making it set matched_src only upon
      unambiguous match.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      3c8b7df1