Commit Graph

1708 Commits

Author SHA1 Message Date
Ulrik Sjolin
b6ea3bfcc3 Honor url.insteadOf when setting up SSH control master connection
Repo can now properly handle url.insteadOf sections in the
user's ~/.gitconfig file.  This means that a user can now enjoy
the master-ssh functionality even if he/she uses insteadOf's in
~/.gitconfig to rewrite git:// URLs to ssh:// style URLs.

Change-Id: Ic0f04a9c57206a7b89eb0f10bf188c4c483debe3
Signed-off-by: Shawn O. Pearce <sop@google.com>
2010-01-04 05:38:39 -08:00
Shawn O. Pearce
aa4982e4c9 sync: Fix split call on malformed email addresses
If an email address in a commit object contains a space, like a few
malformed ones on the Linux kernel, we still want to split only on
the first space.

Unfortunately my brain was too damaged by Perl and originally wrote
the split asking for 2 results; in Python split's argument is how
many splits to perform.  Here we want only 1 split, to break apart
the commit identity from the email address on the same line.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-12-30 18:38:27 -08:00
Nico Sallembien
9bb1816bdc Fixing project renaming bug.
This bug happens when a project gets added to the manifest, and
then is renamed. Users who happened to have run "repo sync" after
the project was added but before the rename happened will try to
read the data from the old project, as the manifest was only updated
after all projects were updated successfully.
2009-12-10 15:24:45 -08:00
Thiago Farina
840ed0fab7 Fix to display the usage message of the command download when the user
don't provide any arguments to 'repo download'.

Signed-off-by: Thiago Farina <thiago.farina@gmail.com>
2009-09-09 00:41:34 -04:00
Shawn O. Pearce
c024912fb8 commit-msg: Don't create message with only Change-Id
If a user aborts a commit, the commit-msg hook is still called,
but with an empty file.  We need to leave the empty file alone.

Change-Id: I13766135dac267823cb08ab76f67d2000ba2d1ce
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-08-25 12:03:55 -07:00
Shawn O. Pearce
15f6579eb3 commit-msg: Update the commit message hook
This version fixes a bug where Change-Id lines become the subject
line, if the subject used a pattern like the subject of this
message does.

Change-Id: I7f7e0363091d03eb05dead2992fc19763214de65
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-08-22 19:23:55 -07:00
Shawn O. Pearce
d4cd69bdef forall: Silently skip missing projects
If a project is missing locally, it might be OK to skip over it
and continue running the same command in other projects.

Bug: REPO-43
Change-Id: I64f97eb315f379ab2c51fc53d24ed340b3d09250
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-08-22 18:51:02 -07:00
Shawn O. Pearce
d2dfac81ad upload: Catch and cleanly report connectivity errors
Instead of giving a Python backtrace when there is a connectivity
problem during repo upload, report that we cannot access the host,
and why, with a halfway decent error message.

Bug: REPO-45
Change-Id: I9a45b387e86e48073a2d99bd6d594c1a7d6d99d4
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-08-22 18:41:16 -07:00
Shawn O. Pearce
4719901067 upload: Document --replace is deprecated
Change-Id: I52715bcfec9c038d0e02505aa7e4054ebc0434aa
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-08-22 18:41:09 -07:00
Shawn O. Pearce
a949fa5d20 Automatically install Gerrit Code Review's commit-msg hook
Most users of repo are also using Gerrit Code Review, and will want
the commit-msg hook to be automatically installed into their local
projects so that Change-Ids are assigned when commits are created,
not when they are first uploaded.

Change-Id: Ide42e93b068832f099d68a79c2863d22145d05ad
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-08-22 18:22:04 -07:00
Shawn O. Pearce
0afac0856c Merge change 11206
* change 11206:
  Do not invoke ssh with -p argument when no port has been specified.
2009-08-17 08:09:05 -07:00
Josh Guilfoyle
4c0f670465 Do not invoke ssh with -p argument when no port has been specified.
This change allows local SSH configuration to choose the port number to
use when not explicitly set in the manifest.
2009-08-16 11:26:57 -07:00
Mike Lockwood
33f0e786bb Add "repo branch" as an alias for "repo branches"
For those of us that are used to typing "git branch".

Signed-off-by: Mike Lockwood <lockwood@android.com>
2009-07-14 15:23:39 -04:00
Shawn O. Pearce
57272ba82e manifest: Support --upgrade to submodule format, from XML
By running `repo manifest --uprade` an administrator can update the
current manifest format from the XML format to submodule format, but
we need all projects to be checked out in a work tree for this to
function correctly.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 20:51:13 -07:00
Shawn O. Pearce
0125ae2fda Introduce manifest format using git submodules
If a manifest top level directory contains '.gitmodules' we now
assume this is a git module format manifest and switch to using
that code, rather than the legacy XML based manifest.

At the same time, we move the bare repository for a project from
$TOP/.repo/projects/$REPO_PATH.git to be $REPO_NAME.git instead.
This makes it easier for us to later support a repo init from an
existing work tree, as we can more accurately predict the path of
the project's repository in the workspace.  It also means that the
$TOP/.repo/projects/ directory is layed out like a mirror would be.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 20:50:52 -07:00
Shawn O. Pearce
a7ce096047 Allow meta projects to be created not under .repo/
Some types of manifests might prefer to put their meta project work
tree under topdir, rather than inside of the .repo/ directory.  We
can support that by allowing relpath to be optionally passed in.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 20:50:52 -07:00
Shawn O. Pearce
87bda12e85 sync: Support upgrading manifest formats
If the manifest format changes during init or sync we need to do
a full reparse of the manifest, and possibly allow the new object
to reconfigure the local workspace to match its expectations.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 20:50:52 -07:00
Shawn O. Pearce
5f947bba69 init: add -o, --origin to name manifest remote
The -o option permits the user to control the name of the manifest's
remote, which normally is hardcoded to be 'origin', but can differ
because we derive it at runtime from the configuration file.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 20:50:52 -07:00
Shawn O. Pearce
b3d2c9214b init (wrapper): Note that -m is now deprecated
If the manifest format isn't XML, this option isn't available.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 20:50:52 -07:00
Shawn O. Pearce
7354d88914 init: Ensure repo.mirror is noticed once set
If we don't clear the cache, there can be a timestamp race between
the pickle file and the raw text file, and we may not pick up the
edit when we create a new config object around the same path name.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 20:50:52 -07:00
Shawn O. Pearce
ce86abbe8a Allow the manifest to be accessed it if is in work tree
If the manifest's work tree is actually inside of the rest of
the client work tree then its only fair that we include it as
a project that the user can access.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 20:03:38 -07:00
Shawn O. Pearce
75b87c8a51 Abstract manifest branch creation from init to the manifest object
This permits the XML style manifest to use 'default', while other
types can use their own creation strategy for the current branch.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 20:03:38 -07:00
Shawn O. Pearce
abb7a3dfec Allow callers to request a specific type of manifest
If the caller knows exactly what the manifest type must be we
can now ask the loader to directly construct that type, rather
than guessing it from the working directory.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 20:03:38 -07:00
Shawn O. Pearce
cc6c79643e Make refs/remotes/m management the manifest object's responsibility
I plan to have the new submodule manifest format use a different
layout for the m refs than the XML manifest format has used in
the past.  Thus we need to move the behavior management into the
manifest object, and out of the project, so we can change it.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 20:03:38 -07:00
Shawn O. Pearce
2095179bee Cleanup import formatting in manifest_xml.py
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 20:03:38 -07:00
Shawn O. Pearce
b0ca41e19a Only remove a stale pickle file if it exists
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 20:03:38 -07:00
Shawn O. Pearce
1875ddd47c sync: Run git gc --auto after fetch
Users may wind up with a lot of loose object content in projects they
don't frequently make changes in, but that are modified by others.

Since we bypass many git code paths that would have otherwise called
out to `git gc --auto`, its possible for these projects to have
their loose object database grow out of control.  To help prevent
that, we now invoke it ourselves during the network half of sync.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 16:39:19 -07:00
Shawn O. Pearce
446c4e5556 init: Allow -m only on XML formatted manifest
If the manifest is the newer SubmoduleManifest style, then the -m
option makes no sense, as you cannot select a specific file within
the current branch.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 11:00:16 -07:00
Shawn O. Pearce
67f4563acb manifest: Only support -o option on XML formatted manifest
If the manifest isn't a single file format manifest, the -o option
makes no sense, as you cannot export multiple files to a single
stream for display or redirection.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 11:00:16 -07:00
Shawn O. Pearce
050e4fd591 manifest: Only display XML help on XML manifest
Some of the help text is only related to the XML formatted manifest,
so only display that text if that is the current format.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 11:00:16 -07:00
Shawn O. Pearce
60e679209a help: Don't show empty Summary or Description sections
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 11:00:16 -07:00
Shawn O. Pearce
f1a6b14fdc Create an abstract Manifest base class
This will help as we add support for another manifest type.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 11:00:16 -07:00
Shawn O. Pearce
ca3d8ff4fc Teach Project how to relink a .git/ in the work tree
The _LinkWorkTree method can now be used to relink the work tree,
such as if the real repository was moved to a different location
on disk.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 11:00:16 -07:00
Shawn O. Pearce
98ea26b8d8 Allow callers to reset the git config cache
If commands modify the git config too rapidly we might not notice
the .git/config file has been modified, as they could run in the
same filesystem timestamp window and thus not cause a change on
the config's mtime.  This can cause repo to miss re-reading the
config file after running a command.

Allowing the cache to be flushed forces us to re-read the config.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-03 11:00:16 -07:00
Shawn O. Pearce
c24c720b61 Fix error parsing a non-existant configuration file
If a file (e.g. ~/.gitconfig) does not exist, we get None
here rather than a string.  NoneType lacks rstrip() so we
cannot strip it.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-02 16:12:57 -07:00
Shawn O. Pearce
2d1a396897 Document how to contribute to the repo project
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-02 13:18:55 -07:00
Shawn O. Pearce
1dcb58a7d0 Support GIT_EDITOR='vim -c "set textwidth=80"'
If there are shell special characters in the editor string, we must
use /bin/sh to parse and execute it, rather than trying to rely on
a simple split(' ').  This avoids vim starting up with two empty
buffers, due to a misparsed command line.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-02 12:45:47 -07:00
Shawn O. Pearce
37dbf2bf0f Try to prevent 'repo sync' as a user name
When someone copies and pastes a setup line from a web page,
they might actually copy 'repo sync' onto the clipboard and wind
up pasting it into the "Your Name" prompt.  This means they will
initialize their client with the user name of "repo sync", creating
some rather funny looking commits later on.  For example:

  To setup your source tree:

    mkdir ~/code
    cd ~/code
    repo init -u git://....
    repo sync

If this entire block was just blindly copy and pasted into the
terminal, the shell won't read "repo sync" but "repo init" will.

By showing the user their full identity string, and asking them
to confirm it before we continue, we can give the hapless user a
chance to recover from this mistake, without unfairly harming those
who were actually named 'repo' by their parents.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-07-02 10:53:04 -07:00
David Aguilar
438c54713a git_config: handle configuration entries with no values
A git-config entry with no value was preventing repo
from initializing.  This modifies _ReadGit() to handle
config entries with empty values.

Signed-off-by: David Aguilar <davvid@gmail.com>
Reported-by: Josh Guilfoyle <jasta00@gmail.com>
2009-06-29 00:24:36 -07:00
David Aguilar
e020ebee4e .gitignore: add an entry for repopickles
Signed-off-by: David Aguilar <davvid@gmail.com>
2009-06-28 15:08:56 -07:00
Shawn O. Pearce
21c5c34ee2 Support detached HEAD in manifest repository
If the manifest repository is on a detached HEAD and we are parsing
an XML formatted manifest we should simply set the branch property
to None, rather than crash with an AttributeError.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-06-25 16:47:30 -07:00
Shawn O. Pearce
54fccd71fb Document any crashes from the user's text editor
Rather than failing with no information, display the child exit
status and the command line we tried to use to edit a text file.
There may be some useful information to help understand the crash.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-06-24 07:15:21 -07:00
Shawn O. Pearce
fb5c8fd948 Fix invalid use of try-catch
Its try-except in Python.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-06-16 14:59:19 -07:00
Shawn O. Pearce
26120ca18d Don't crash if the ssh client is already dead
If the SSH client terminated abnormally in the background (e.g. the
server shutdown while we were doing a sync) then the pid won't exist.
Instead of crashing, ignore it, the result we wanted (a non-orphaned
ssh process) is already acheived.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-06-16 11:49:10 -07:00
Shawn O. Pearce
7da73d6f3b branches: Describe output format in repo help branches
Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-06-12 17:35:43 -07:00
Shawn O. Pearce
f0d4c36701 grep: Only use --color on git 1.6.3 and later
The --color flag wasn't introduced until git 1.6.3.  Prior to that
version, `git grep --color` just produces a fatal error, as it is
an unsupported option.  Since this is just pretty output and is not
critical to execution, we can simply omit the option if the version
of git we are running on doesn't support it.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-06-12 09:33:48 -07:00
Shawn O. Pearce
2ec00b9272 Refactor git version detection for reuse
This way we can use it to detect feature support in the underlying
git, such as new options or commands that have been added in more
recent versions.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-06-12 09:32:50 -07:00
Shawn O. Pearce
2a3a81b51f Ignore EOFError when reading a truncated pickle file
If the pickle config file is 0 bytes in length,  we may have
crashed (or been aborted) while writing the file out to disk.
Instead of crashing with a backtrace, just treat the file as
though it wasn't present and load off a `git config` fork.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-06-12 09:10:07 -07:00
Shawn O. Pearce
7b4f43542a Add missing return False to preconnect
Noticed by users on repo-discuss, we were missing a return False
here to signal that SSH control master was not used to setup the
network connection.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-06-12 09:08:34 -07:00
Shawn O. Pearce
9fb29ce123 sync: Keep the project.list file sorted
Its easier to locate an entry visually if the file is sorted.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2009-06-04 20:41:26 -07:00