The import and pick commands can get the patch name from the patch
description if it wasn't passed on the command line or the patch is read
from the standard input (for import).
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
raise CmdException, 'Incorrect "name <email> date" string: %s' % address
return str_list[0]
raise CmdException, 'Incorrect "name <email> date" string: %s' % address
return str_list[0]
+
+def make_patch_name(msg):
+ """Return a string to be used as a patch name. This is generated
+ from the top line of the string passed as argument.
+ """
+ if not msg:
+ return None
+
+ subject_line = msg.lstrip().split('\n', 1)[0]
+ return re.sub('[\W]+', '-', subject_line).strip('-')
message, author_name, author_email, author_date = \
__parse_patch(filename)
message, author_name, author_email, author_date = \
__parse_patch(filename)
+ if not patch:
+ patch = make_patch_name(message)
+ if not patch:
+ raise CmdException, 'Unknown patch name'
+
# refresh_patch() will invoke the editor in this case, with correct
# patch content
if not message:
# refresh_patch() will invoke the editor in this case, with correct
# patch content
if not message:
elif filename:
patch = os.path.basename(filename)
else:
elif filename:
patch = os.path.basename(filename)
else:
- raise CmdException, 'Unknown patch name'
if options.strip:
patch = __strip_patch_name(patch)
if options.strip:
patch = __strip_patch_name(patch)
check_head_top_equal()
commit_str = args[0]
check_head_top_equal()
commit_str = args[0]
+ commit_id = git_id(commit_str)
+ commit = git.Commit(commit_id)
if options.fold or options.update:
if not crt_series.get_current():
if options.fold or options.update:
if not crt_series.get_current():
elif len(patch_branch) == 2:
patch = patch_branch[0]
else:
elif len(patch_branch) == 2:
patch = patch_branch[0]
else:
- raise CmdException, 'Unknown patch name'
-
- commit_id = git_id(commit_str)
- commit = git.Commit(commit_id)
+ patch = make_patch_name(commit.get_log())
+ if not patch:
+ raise CmdException, 'Unknown patch name'
if not options.reverse:
bottom = commit.get_parent()
if not options.reverse:
bottom = commit.get_parent()