Skip to content

Commit bb10f75

Browse files
committed
allow relative --link; accept fix --old-link and log
1 parent 35f57b3 commit bb10f75

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

git_sym.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ def git_sym_add(paths, **args):
312312
with cd(GIT_SYM_DIR):
313313
retrieve(needed)
314314
git_sym_show(paths)
315+
shell('git add %s' %' '.join(paths))
315316
def git_sym_show(symlinks, **args):
316317
if not symlinks:
317318
symlinks = find_all_symlinks()
@@ -332,10 +333,12 @@ def git_sym_missing(symlinks, **arsg):
332333
missing += 1
333334
#if missing:
334335
# raise Exception(missing)
335-
def git_sym_fix(symlinks, **args):
336-
GIT_SYM_VIA_OLD = GIT_SYM_DIR
336+
def git_sym_fix(symlinks, old_link, **args):
337+
GIT_SYM_VIA_OLD = os.path.abspath(old_link)
338+
log('via=%r' %GIT_SYM_VIA_OLD)
337339
if not symlinks:
338340
symlinks = list(find_symlinks(GIT_SYM_VIA_OLD))
341+
log(symlinks)
339342
for sl in symlinks:
340343
fix(sl, GIT_SYM_VIA_OLD, GIT_SYM_LINK)
341344
def main(args):
@@ -345,6 +348,9 @@ def main(args):
345348
if args['debug']:
346349
log = debug = debug_msg
347350
debug(args)
351+
global GIT_SYM_LINK
352+
GIT_SYM_LINK = os.path.abspath(args['link'])
353+
log('GIT_SYM_LINK=%r' %GIT_SYM_LINK)
348354
cmd_table = {
349355
'add': git_sym_add,
350356
'check': git_sym_check,
@@ -411,9 +417,12 @@ def parse_args():
411417
help='If not given, walk through tree to find relevant symlinks.')
412418

413419
parser_fix = subs.add_parser('fix',
414-
help='(IGNORE THIS FOR NOW.) If you add or remove GIT_SYM_LINK from ".gitignore", you will need to alter all symlinks. This does it automatically, but it does not commit the changes. (TODO: Support other changes.)')
420+
help='Change symlinks from OLD_LINK to LINK. `git add` the changes, but do not commit. (This is helpful if you change the LINK.)')
415421
parser_fix.add_argument('symlinks', nargs='*',
416-
help='If not given, walk through tree to find relevant symlinks.')
422+
help='If not given, walk through tree to find relevant symlinks, but with respect to OLD_LINK, not LINK.')
423+
parser_fix.add_argument('--old-link',
424+
default=os.path.join(GIT_ROOT_DIR, '.git', 'git_sym'),
425+
help='[default=%(default)s]')
417426

418427
parser_add = subs.add_parser('add',
419428
help='Move named files/directories to GIT_SYM_CACHE_DIR. Create git-sym symlinks in their places. "git add". You still need to "git commit" before running "git-sym update".')

0 commit comments

Comments
 (0)