Re: [PATCH] Add another fast-import example, this time for .zip files
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jun 30, 2008, 22:53 UTC
- Message-ID
- <alpine.DEB.1.00.0806302352370.9925@racer>
- In-Reply-To
- <alpine.DEB.1.00.0806301948130.9925@racer>
Hi,
On Mon, 30 Jun 2008, Johannes Schindelin wrote:
Show 5 quoted lines
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > --- > > I needed that today.
... and I needed that on top, which I forgot to commit, and therefore never sent in my first mail on this subject:
-- snipsnap --
diff --git a/contrib/fast-import/import-zip.py b/contrib/fast-import/import-zips.py similarity index 85% rename from contrib/fast-import/import-zip.py rename to contrib/fast-import/import-zips.py index 4200a66..fcf5823 100755 --- a/contrib/fast-import/import-zip.py +++ b/contrib/fast-import/import-zips.py @@ -40,6 +40,11 @@ for zipfile in argv[1:]: if commit_time < info.date_time: commit_time = info.date_time + if common_prefix == None: + common_prefix = name[:name.rfind('/') + 1] + else: + while not name.startswith(common_prefix): + common_prefix = name[:name.rfind('/') + 1] mark[name] = ':' + str(next_mark) next_mark += 1 @@ -56,7 +61,8 @@ for zipfile in argv[1:]: '', 'deleteall')) for name in mark.keys(): - fast_import.write('M 100644 ' + mark[name] + ' ' + name + "\n") + fast_import.write('M 100644 ' + mark[name] + ' ' + + name[len(common_prefix):] + "\n") printlines(('', 'tag ' + path.basename(zipfile), \ 'from ' + branch_ref, 'tagger ' + committer, \