- check_conflicts()
- check_head_top_equal(crt_series)
-
- if options.author:
- options.authname, options.authemail = name_email(options.author)
-
- crt_series.new_patch(name, message = options.message,
- show_patch = options.showpatch,
- author_name = options.authname,
- author_email = options.authemail,
- author_date = options.authdate,
- committer_name = options.commname,
- committer_email = options.commemail,
- sign_str = options.sign_str)
+ head = directory.repository.refs.get(directory.repository.head)
+ cd = gitlib.Commitdata(tree = head.data.tree, parents = [head],
+ message = '')
+
+ # Set patch commit message from commandline.
+ if options.message != None:
+ cd = cd.set_message(options.message)
+
+ # Specify author and committer data.
+ if options.author != None:
+ options.authname, options.authemail = common.name_email(options.author)
+ for p, f, val in [('author', 'name', options.authname),
+ ('author', 'email', options.authemail),
+ ('author', 'date', gitlib.Date.maybe(options.authdate)),
+ ('committer', 'name', options.commname),
+ ('committer', 'email', options.commemail)]:
+ if val != None:
+ cd = getattr(cd, 'set_' + p)(
+ getattr(getattr(cd, p), 'set_' + f)(val))
+
+ # Add Signed-off-by: or similar.
+ if options.sign_str != None:
+ cd = cd.set_message(utils.add_sign_line(
+ cd.message, options.sign_str, gitlib.Person.committer().name,
+ gitlib.Person.committer().email))
+
+ # Let user edit the commit message manually.
+ if not options.message:
+ cd = cd.set_message(utils.edit_string(cd.message, '.stgit-new.txt'))
+ if name == None:
+ name = utils.make_patch_name(cd.message,
+ lambda name: stack.patches.exists(name))
+
+ # Write the new patch.
+ iw = stack.repository.default_iw
+ trans = transaction.StackTransaction(stack, 'new')
+ trans.patches[name] = stack.repository.commit(cd)
+ trans.applied.append(name)
+ return trans.run()